Skip to content

Commit c9c7d06

Browse files
authored
Start renaming preview1 to p1 and preview2 to p2 (#478)
* Start renaming preview1 to p1 and preview2 to p2 This is an initial start at renaming the "preview" terminology in WASI targets to "pX". For example the `wasm32-wasi` target should transition to `wasm32-wasip1`, `wasm32-wasi-preview2` should transition to `wasm32-wasip2`, and `wasm32-wasi-threads` should transition to `wasm32-wasip1-threads`. This commit applies a few renames in the `Makefile` such as: * `WASI_SNAPSHOT` is now either "p1" or "p2" * The default p2 target triple is now `wasm32-wasip2` instead of `wasm32-wasi-preview2` (in the hopes that it's early enough to change the default). * Bindings for WASIp2 were renamed from "preview2" terminology to "wasip2". * The expected-defines files are renamed and the logic of which expectation was used has been updated slightly. With this commit the intention is that non-preview2 defaults do not change. For example the default build still produces a `wasm32-wasi` sysroot. If `TARGET_TRIPLE=wasm32-wasip1` is passed, however, then that sysroot is produced instead. Similarly a `THREAD_MODEL=posix` build produces a `wasm32-wasi-threads` sysroot target but you can now also pass `TARGET_TRIPLE=wasm32-wasip1-threads` to rename the sysroot. My hope is to integrate this into the wasi-sdk repository and build a dual sysroot for these new targets for a release or two so both are supported and then in the future the defaults can be switched away from `wasm32-wasi` to `wasm32-wasip1` as built-by-default. * Update builds in CI * Update test workflow * Fix test for wasm32-wasip1-threads * Make github actions rules a bit more readable
1 parent 09683b3 commit c9c7d06

19 files changed

Lines changed: 191 additions & 169 deletions

File tree

.github/workflows/main.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,19 @@ jobs:
8585
- name: Build libc
8686
shell: bash
8787
run: |
88-
make -j4
89-
WASI_SNAPSHOT=preview2 make -j4
88+
make -j4 TARGET_TRIPLE=wasm32-wasi
89+
make -j4 TARGET_TRIPLE=wasm32-wasip1
90+
make -j4 TARGET_TRIPLE=wasm32-wasip2 WASI_SNAPSHOT=p2
9091
9192
- name: Build libc + threads
9293
# Only build the thread-capable wasi-libc in the latest supported Clang
9394
# version; the earliest version does not have all necessary builtins
9495
# (e.g., `__builtin_wasm_memory_atomic_notify`).
9596
if: matrix.clang_version != '10.0.0'
9697
shell: bash
97-
run: make -j4 THREAD_MODEL=posix
98+
run: |
99+
make -j4 THREAD_MODEL=posix TARGET_TRIPLE=wasm32-wasi-threads
100+
make -j4 THREAD_MODEL=posix TARGET_TRIPLE=wasm32-wasip1-threads
98101
99102
- name: Test
100103
shell: bash
@@ -105,13 +108,21 @@ jobs:
105108
cd test
106109
make download
107110
export WASI_DIR=$(realpath $($CLANG_DIR/clang -print-resource-dir)/lib/wasi/)
108-
mkdir -p $WASI_DIR
111+
export WASIP1_DIR=$(realpath $($CLANG_DIR/clang -print-resource-dir)/lib/wasip1/)
112+
export WASIP2_DIR=$(realpath $($CLANG_DIR/clang -print-resource-dir)/lib/wasip2/)
113+
mkdir -p $WASI_DIR $WASIP1_DIR $WASIP2_DIR
109114
cp download/lib/wasi/libclang_rt.builtins-wasm32.a $WASI_DIR
115+
cp download/lib/wasi/libclang_rt.builtins-wasm32.a $WASIP1_DIR
116+
cp download/lib/wasi/libclang_rt.builtins-wasm32.a $WASIP2_DIR
110117
TARGET_TRIPLE=wasm32-wasi make test
111118
rm -r build
112-
TARGET_TRIPLE=wasm32-wasi-preview2 make test
119+
TARGET_TRIPLE=wasm32-wasip1 make test
120+
rm -r build
121+
TARGET_TRIPLE=wasm32-wasip2 make test
113122
rm -r build
114123
TARGET_TRIPLE=wasm32-wasi-threads make test
124+
rm -r build
125+
TARGET_TRIPLE=wasm32-wasip1-threads make test
115126
# The older version of Clang does not provide the expected symbol for the
116127
# test entrypoints: `undefined symbol: __main_argc_argv`.
117128
# The older (<15.0.7) version of wasm-ld does not provide `__heap_end`,

Makefile

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@ SYSROOT ?= $(CURDIR)/sysroot
1515
INSTALL_DIR ?= /usr/local
1616
# single or posix; note that pthread support is still a work-in-progress.
1717
THREAD_MODEL ?= single
18-
# preview1 or preview2; the latter is not (yet) compatible with multithreading
19-
WASI_SNAPSHOT ?= preview1
18+
# p1 or p2; the latter is not (yet) compatible with multithreading
19+
WASI_SNAPSHOT ?= p1
2020
# dlmalloc or none
2121
MALLOC_IMPL ?= dlmalloc
2222
# yes or no
2323
BUILD_LIBC_TOP_HALF ?= yes
2424
# The directory where we will store intermediate artifacts.
2525
OBJDIR ?= build/$(TARGET_TRIPLE)
26-
# The directory where we store files and tools for generating WASI Preview 2 bindings
26+
# The directory where we store files and tools for generating WASIp2 bindings
2727
BINDING_WORK_DIR ?= build/bindings
28-
# URL from which to retrieve the WIT files used to generate the WASI Preview 2 bindings
28+
# URL from which to retrieve the WIT files used to generate the WASIp2 bindings
2929
WASI_CLI_URL ?= https://github.com/WebAssembly/wasi-cli/archive/refs/tags/v0.2.0.tar.gz
30-
# URL from which to retrieve the `wit-bindgen` command used to generate the WASI
31-
# Preview 2 bindings.
30+
# URL from which to retrieve the `wit-bindgen` command used to generate the
31+
# WASIp2 bindings.
3232
WIT_BINDGEN_URL ?= https://github.com/bytecodealliance/wit-bindgen/releases/download/wit-bindgen-cli-0.17.0/wit-bindgen-v0.17.0-x86_64-linux.tar.gz
3333

3434
# When the length is no larger than this threshold, we consider the
@@ -50,8 +50,8 @@ ifeq ($(THREAD_MODEL), posix)
5050
TARGET_TRIPLE = wasm32-wasi-threads
5151
endif
5252

53-
ifeq ($(WASI_SNAPSHOT), preview2)
54-
TARGET_TRIPLE = wasm32-wasi-preview2
53+
ifeq ($(WASI_SNAPSHOT), p2)
54+
TARGET_TRIPLE = wasm32-wasip2
5555
endif
5656

5757
BUILTINS_LIB ?= $(shell ${CC} --print-libgcc-file-name)
@@ -75,16 +75,16 @@ LIBC_BOTTOM_HALF_ALL_SOURCES = \
7575
$(shell find $(LIBC_BOTTOM_HALF_CLOUDLIBC_SRC) -name \*.c) \
7676
$(shell find $(LIBC_BOTTOM_HALF_SOURCES) -name \*.c))
7777

78-
ifeq ($(WASI_SNAPSHOT), preview1)
79-
# Omit source files not relevant to WASI Preview 1. As we introduce files
80-
# supporting `wasi-sockets` for `wasm32-wasi-preview2`, we'll add those files to
78+
ifeq ($(WASI_SNAPSHOT), p1)
79+
# Omit source files not relevant to WASIp1. As we introduce files
80+
# supporting `wasi-sockets` for `wasm32-wasip2`, we'll add those files to
8181
# this list.
8282
LIBC_BOTTOM_HALF_OMIT_SOURCES := \
83-
$(LIBC_BOTTOM_HALF_SOURCES)/preview2.c \
83+
$(LIBC_BOTTOM_HALF_SOURCES)/wasip2.c \
8484
$(LIBC_BOTTOM_HALF_SOURCES)/descriptor_table.c
8585
LIBC_BOTTOM_HALF_ALL_SOURCES := $(filter-out $(LIBC_BOTTOM_HALF_OMIT_SOURCES),$(LIBC_BOTTOM_HALF_ALL_SOURCES))
86-
# Omit preview2-specific headers from include-all.c test.
87-
INCLUDE_ALL_CLAUSES := -not -name preview2.h -not -name descriptor_table.h
86+
# Omit p2-specific headers from include-all.c test.
87+
INCLUDE_ALL_CLAUSES := -not -name wasip2.h -not -name descriptor_table.h
8888
endif
8989

9090
# FIXME(https://reviews.llvm.org/D85567) - due to a bug in LLD the weak
@@ -382,8 +382,8 @@ DLMALLOC_OBJS = $(call objs,$(DLMALLOC_SOURCES))
382382
EMMALLOC_OBJS = $(call objs,$(EMMALLOC_SOURCES))
383383
LIBC_BOTTOM_HALF_ALL_OBJS = $(call objs,$(LIBC_BOTTOM_HALF_ALL_SOURCES))
384384
LIBC_TOP_HALF_ALL_OBJS = $(call asmobjs,$(call objs,$(LIBC_TOP_HALF_ALL_SOURCES)))
385-
ifeq ($(WASI_SNAPSHOT), preview2)
386-
LIBC_OBJS += $(OBJDIR)/preview2_component_type.o
385+
ifeq ($(WASI_SNAPSHOT), p2)
386+
LIBC_OBJS += $(OBJDIR)/wasip2_component_type.o
387387
endif
388388
ifeq ($(MALLOC_IMPL),dlmalloc)
389389
LIBC_OBJS += $(DLMALLOC_OBJS)
@@ -606,7 +606,7 @@ $(OBJDIR)/%.long-double.pic.o: %.c include_dirs
606606
@mkdir -p "$(@D)"
607607
$(CC) $(CFLAGS) -MD -MP -o $@ -c $<
608608

609-
$(OBJDIR)/preview2_component_type.pic.o $(OBJDIR)/preview2_component_type.o: $(LIBC_BOTTOM_HALF_SOURCES)/preview2_component_type.o
609+
$(OBJDIR)/wasip2_component_type.pic.o $(OBJDIR)/wasip2_component_type.o: $(LIBC_BOTTOM_HALF_SOURCES)/wasip2_component_type.o
610610
@mkdir -p "$(@D)"
611611
cp $< $@
612612

@@ -741,6 +741,17 @@ endif
741741
DEFINED_SYMBOLS = $(SYSROOT_SHARE)/defined-symbols.txt
742742
UNDEFINED_SYMBOLS = $(SYSROOT_SHARE)/undefined-symbols.txt
743743

744+
ifeq ($(WASI_SNAPSHOT),p2)
745+
EXPECTED_TARGET_DIR = expected/wasm32-wasip2
746+
else
747+
ifeq ($(THREAD_MODEL),posix)
748+
EXPECTED_TARGET_DIR = expected/wasm32-wasip1-threads
749+
else
750+
EXPECTED_TARGET_DIR = expected/wasm32-wasip1
751+
endif
752+
endif
753+
754+
744755
check-symbols: startup_files libc
745756
#
746757
# Collect metadata on the sysroot and perform sanity checks.
@@ -836,7 +847,7 @@ check-symbols: startup_files libc
836847

837848
# Check that the computed metadata matches the expected metadata.
838849
# This ignores whitespace because on Windows the output has CRLF line endings.
839-
diff -wur "expected/$(TARGET_TRIPLE)" "$(SYSROOT_SHARE)"
850+
diff -wur "$(EXPECTED_TARGET_DIR)" "$(SYSROOT_SHARE)"
840851

841852
install: finish
842853
mkdir -p "$(INSTALL_DIR)"
@@ -860,7 +871,7 @@ bindings: $(BINDING_WORK_DIR)/wasi-cli $(BINDING_WORK_DIR)/wit-bindgen
860871
cd "$(BINDING_WORK_DIR)" && \
861872
./wit-bindgen/wit-bindgen c \
862873
--autodrop-borrows yes \
863-
--rename-world preview2 \
874+
--rename-world wasip2 \
864875
--type-section-suffix __wasi_libc \
865876
--world wasi:cli/imports@0.2.0 \
866877
--rename wasi:clocks/monotonic-clock@0.2.0=monotonic_clock \
@@ -891,12 +902,12 @@ bindings: $(BINDING_WORK_DIR)/wasi-cli $(BINDING_WORK_DIR)/wit-bindgen
891902
--rename wasi:cli/terminal-stdout@0.2.0=terminal_stdout \
892903
--rename wasi:cli/terminal-stderr@0.2.0=terminal_stderr \
893904
./wasi-cli/wit && \
894-
mv preview2.h ../../libc-bottom-half/headers/public/wasi/ && \
895-
mv preview2_component_type.o ../../libc-bottom-half/sources && \
896-
sed 's_#include "preview2\.h"_#include "wasi/preview2.h"_' \
897-
< preview2.c \
898-
> ../../libc-bottom-half/sources/preview2.c && \
899-
rm preview2.c
905+
mv wasip2.h ../../libc-bottom-half/headers/public/wasi/ && \
906+
mv wasip2_component_type.o ../../libc-bottom-half/sources && \
907+
sed 's_#include "wasip2\.h"_#include "wasi/wasip2.h"_' \
908+
< wasip2.c \
909+
> ../../libc-bottom-half/sources/wasip2.c && \
910+
rm wasip2.c
900911

901912

902913
clean:
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)