Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start renaming preview1 to p1 and preview2 to p2 #478

Merged
merged 5 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,19 @@ jobs:
- name: Build libc
shell: bash
run: |
make -j4
WASI_SNAPSHOT=preview2 make -j4
make -j4 TARGET_TRIPLE=wasm32-wasi
make -j4 TARGET_TRIPLE=wasm32-wasip1
make -j4 TARGET_TRIPLE=wasm32-wasip2 WASI_SNAPSHOT=p2

- name: Build libc + threads
# Only build the thread-capable wasi-libc in the latest supported Clang
# version; the earliest version does not have all necessary builtins
# (e.g., `__builtin_wasm_memory_atomic_notify`).
if: matrix.clang_version != '10.0.0'
shell: bash
run: make -j4 THREAD_MODEL=posix
run: |
make -j4 THREAD_MODEL=posix TARGET_TRIPLE=wasm32-wasi-threads
make -j4 THREAD_MODEL=posix TARGET_TRIPLE=wasm32-wasip1-threads

- name: Test
shell: bash
Expand All @@ -105,13 +108,21 @@ jobs:
cd test
make download
export WASI_DIR=$(realpath $($CLANG_DIR/clang -print-resource-dir)/lib/wasi/)
mkdir -p $WASI_DIR
export WASIP1_DIR=$(realpath $($CLANG_DIR/clang -print-resource-dir)/lib/wasip1/)
export WASIP2_DIR=$(realpath $($CLANG_DIR/clang -print-resource-dir)/lib/wasip2/)
mkdir -p $WASI_DIR $WASIP1_DIR $WASIP2_DIR
cp download/lib/wasi/libclang_rt.builtins-wasm32.a $WASI_DIR
cp download/lib/wasi/libclang_rt.builtins-wasm32.a $WASIP1_DIR
cp download/lib/wasi/libclang_rt.builtins-wasm32.a $WASIP2_DIR
TARGET_TRIPLE=wasm32-wasi make test
rm -r build
TARGET_TRIPLE=wasm32-wasi-preview2 make test
TARGET_TRIPLE=wasm32-wasip1 make test
rm -r build
TARGET_TRIPLE=wasm32-wasip2 make test
rm -r build
TARGET_TRIPLE=wasm32-wasi-threads make test
rm -r build
TARGET_TRIPLE=wasm32-wasip1-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
61 changes: 36 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ SYSROOT ?= $(CURDIR)/sysroot
INSTALL_DIR ?= /usr/local
# single or posix; note that pthread support is still a work-in-progress.
THREAD_MODEL ?= single
# preview1 or preview2; the latter is not (yet) compatible with multithreading
WASI_SNAPSHOT ?= preview1
# p1 or p2; the latter is not (yet) compatible with multithreading
WASI_SNAPSHOT ?= p1
# dlmalloc or none
MALLOC_IMPL ?= dlmalloc
# yes or no
BUILD_LIBC_TOP_HALF ?= yes
# The directory where we will store intermediate artifacts.
OBJDIR ?= build/$(TARGET_TRIPLE)
# The directory where we store files and tools for generating WASI Preview 2 bindings
# The directory where we store files and tools for generating WASIp2 bindings
BINDING_WORK_DIR ?= build/bindings
# URL from which to retrieve the WIT files used to generate the WASI Preview 2 bindings
# URL from which to retrieve the WIT files used to generate the WASIp2 bindings
WASI_CLI_URL ?= https://github.com/WebAssembly/wasi-cli/archive/refs/tags/v0.2.0.tar.gz
# URL from which to retrieve the `wit-bindgen` command used to generate the WASI
# Preview 2 bindings.
# URL from which to retrieve the `wit-bindgen` command used to generate the
# WASIp2 bindings.
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

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

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

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

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

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

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

Expand Down Expand Up @@ -741,6 +741,17 @@ endif
DEFINED_SYMBOLS = $(SYSROOT_SHARE)/defined-symbols.txt
UNDEFINED_SYMBOLS = $(SYSROOT_SHARE)/undefined-symbols.txt

ifeq ($(WASI_SNAPSHOT),p2)
EXPECTED_TARGET_DIR = expected/wasm32-wasip2
else
ifeq ($(THREAD_MODEL),posix)
EXPECTED_TARGET_DIR = expected/wasm32-wasip1-threads
else
EXPECTED_TARGET_DIR = expected/wasm32-wasip1
endif
endif


check-symbols: startup_files libc
#
# Collect metadata on the sysroot and perform sanity checks.
Expand Down Expand Up @@ -836,7 +847,7 @@ check-symbols: startup_files libc

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

install: finish
mkdir -p "$(INSTALL_DIR)"
Expand All @@ -860,7 +871,7 @@ bindings: $(BINDING_WORK_DIR)/wasi-cli $(BINDING_WORK_DIR)/wit-bindgen
cd "$(BINDING_WORK_DIR)" && \
./wit-bindgen/wit-bindgen c \
--autodrop-borrows yes \
--rename-world preview2 \
--rename-world wasip2 \
--type-section-suffix __wasi_libc \
--world wasi:cli/imports@0.2.0 \
--rename wasi:clocks/monotonic-clock@0.2.0=monotonic_clock \
Expand Down Expand Up @@ -891,12 +902,12 @@ bindings: $(BINDING_WORK_DIR)/wasi-cli $(BINDING_WORK_DIR)/wit-bindgen
--rename wasi:cli/terminal-stdout@0.2.0=terminal_stdout \
--rename wasi:cli/terminal-stderr@0.2.0=terminal_stderr \
./wasi-cli/wit && \
mv preview2.h ../../libc-bottom-half/headers/public/wasi/ && \
mv preview2_component_type.o ../../libc-bottom-half/sources && \
sed 's_#include "preview2\.h"_#include "wasi/preview2.h"_' \
< preview2.c \
> ../../libc-bottom-half/sources/preview2.c && \
rm preview2.c
mv wasip2.h ../../libc-bottom-half/headers/public/wasi/ && \
mv wasip2_component_type.o ../../libc-bottom-half/sources && \
sed 's_#include "wasip2\.h"_#include "wasi/wasip2.h"_' \
< wasip2.c \
> ../../libc-bottom-half/sources/wasip2.c && \
rm wasip2.c


clean:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ __c_locale
__clock
__clock_gettime
__clock_nanosleep
__component_type_object_force_link_preview2
__component_type_object_force_link_preview2_public_use_in_this_compilation_unit
__component_type_object_force_link_wasip2
__component_type_object_force_link_wasip2_public_use_in_this_compilation_unit
__cos
__cosdf
__cosl
Expand Down Expand Up @@ -1008,15 +1008,6 @@ 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 @@ -1384,6 +1375,15 @@ vwprintf
vwscanf
wall_clock_now
wall_clock_resolution
wasip2_list_string_free
wasip2_list_tuple2_string_string_free
wasip2_list_u32_free
wasip2_list_u8_free
wasip2_option_string_free
wasip2_string_dup
wasip2_string_free
wasip2_string_set
wasip2_tuple2_string_string_free
wcpcpy
wcpncpy
wcrtomb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,6 @@
#include <wasi/libc-find-relpath.h>
#include <wasi/libc-nocwd.h>
#include <wasi/libc.h>
#include <wasi/preview2.h>
#include <wasi/wasip2.h>
#include <wchar.h>
#include <wctype.h>
Original file line number Diff line number Diff line change
Expand Up @@ -2474,7 +2474,7 @@
#define __BIGGEST_ALIGNMENT__ 16
#define __BIG_ENDIAN 4321
#define __BIND 19950621
#define __BINDINGS_PREVIEW2_H
#define __BINDINGS_WASIP2_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 libc-bottom-half/headers/private/wasi/descriptor_table.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef DESCRIPTOR_TABLE_H
#define DESCRIPTOR_TABLE_H

#include <wasi/preview2.h>
#include <wasi/wasip2.h>

typedef struct {
int dummy;
Expand Down
Loading