Skip to content

Commit

Permalink
add preview2_component_type.o to libc.a and libc.so
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
dicej committed Feb 12, 2024
1 parent cc62fa8 commit e6fbe0c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 $<
Expand Down
1 change: 1 addition & 0 deletions expected/wasm32-wasi-preview2/defined-symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion expected/wasm32-wasi-preview2/undefined-symbols.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
__addtf3
__component_type_object_force_link_preview2
__divtf3
__eqtf2
__extenddftf2
Expand Down

0 comments on commit e6fbe0c

Please sign in to comment.