From e6fbe0ca51de8b3a2dd08a20e324748a4fc6ddcd Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 12 Feb 2024 14:52:15 -0700 Subject: [PATCH] add preview2_component_type.o to libc.a and libc.so This file adds a custom section to each core module linked with wasi-libc. That custom section contains component type information needed by e.g. `wasm-tools component new` to generate a component from the module. It will be required once we start using any part of WASI 0.2.0 directly (vs. via a Preview 1 adapter). In addition, it allows developers to `#include ` in their code and make use of those APIs directly even if wasi-libc is not using them yet. Signed-off-by: Joel Dice --- Makefile | 7 +++++++ expected/wasm32-wasi-preview2/defined-symbols.txt | 1 + expected/wasm32-wasi-preview2/undefined-symbols.txt | 1 - 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b96ba3358..f56df602e 100644 --- a/Makefile +++ b/Makefile @@ -383,6 +383,9 @@ 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 +endif ifeq ($(MALLOC_IMPL),dlmalloc) LIBC_OBJS += $(DLMALLOC_OBJS) else ifeq ($(MALLOC_IMPL),emmalloc) @@ -604,6 +607,10 @@ $(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 + @mkdir -p "$(@D)" + cp $< $@ + $(OBJDIR)/%.pic.o: %.c include_dirs @mkdir -p "$(@D)" $(CC) $(CFLAGS) -MD -MP -o $@ -c $< diff --git a/expected/wasm32-wasi-preview2/defined-symbols.txt b/expected/wasm32-wasi-preview2/defined-symbols.txt index dea0473c3..c006f1966 100644 --- a/expected/wasm32-wasi-preview2/defined-symbols.txt +++ b/expected/wasm32-wasi-preview2/defined-symbols.txt @@ -19,6 +19,7 @@ __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 __cos __cosdf diff --git a/expected/wasm32-wasi-preview2/undefined-symbols.txt b/expected/wasm32-wasi-preview2/undefined-symbols.txt index c19715b47..ce418c67c 100644 --- a/expected/wasm32-wasi-preview2/undefined-symbols.txt +++ b/expected/wasm32-wasi-preview2/undefined-symbols.txt @@ -1,5 +1,4 @@ __addtf3 -__component_type_object_force_link_preview2 __divtf3 __eqtf2 __extenddftf2