Skip to content

Commit 0fe51d2

Browse files
authored
add preview2_component_type.o to libc.a and libc.so (#472)
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 <wasi/preview2.h>` in their code and make use of those APIs directly even if wasi-libc is not using them yet. Signed-off-by: Joel Dice <joel.dice@fermyon.com>
1 parent 55df1f5 commit 0fe51d2

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,9 @@ DLMALLOC_OBJS = $(call objs,$(DLMALLOC_SOURCES))
380380
EMMALLOC_OBJS = $(call objs,$(EMMALLOC_SOURCES))
381381
LIBC_BOTTOM_HALF_ALL_OBJS = $(call objs,$(LIBC_BOTTOM_HALF_ALL_SOURCES))
382382
LIBC_TOP_HALF_ALL_OBJS = $(call asmobjs,$(call objs,$(LIBC_TOP_HALF_ALL_SOURCES)))
383+
ifeq ($(WASI_SNAPSHOT), preview2)
384+
LIBC_OBJS += $(OBJDIR)/preview2_component_type.o
385+
endif
383386
ifeq ($(MALLOC_IMPL),dlmalloc)
384387
LIBC_OBJS += $(DLMALLOC_OBJS)
385388
else ifeq ($(MALLOC_IMPL),emmalloc)
@@ -601,6 +604,10 @@ $(OBJDIR)/%.long-double.pic.o: %.c include_dirs
601604
@mkdir -p "$(@D)"
602605
$(CC) $(CFLAGS) -MD -MP -o $@ -c $<
603606

607+
$(OBJDIR)/preview2_component_type.pic.o $(OBJDIR)/preview2_component_type.o: $(LIBC_BOTTOM_HALF_SOURCES)/preview2_component_type.o
608+
@mkdir -p "$(@D)"
609+
cp $< $@
610+
604611
$(OBJDIR)/%.pic.o: %.c include_dirs
605612
@mkdir -p "$(@D)"
606613
$(CC) $(CFLAGS) -MD -MP -o $@ -c $<

expected/wasm32-wasi-preview2/defined-symbols.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ __c_locale
1919
__clock
2020
__clock_gettime
2121
__clock_nanosleep
22+
__component_type_object_force_link_preview2
2223
__component_type_object_force_link_preview2_public_use_in_this_compilation_unit
2324
__cos
2425
__cosdf

expected/wasm32-wasi-preview2/undefined-symbols.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
__addtf3
2-
__component_type_object_force_link_preview2
32
__divtf3
43
__eqtf2
54
__extenddftf2

0 commit comments

Comments
 (0)