Skip to content

Commit

Permalink
Merge pull request #450 from ruby/pr-2fcb4e784ebc17ba2ab007511987950b…
Browse files Browse the repository at this point in the history
…1e020b25

PIC support in js gem
  • Loading branch information
kateinoigakukun authored May 5, 2024
2 parents 148b81c + 0d9b427 commit 3cd8627
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/gems/js/ext/js/depend
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ bindgen/legacy/%.o: $(srcdir)/bindgen/legacy/%.c

bindgen/ext.o: $(srcdir)/bindgen/ext.c
@mkdir -p "$(@D)"
$(CC) -c -o $@ $<
$(ECHO) compiling $(<)
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
11 changes: 10 additions & 1 deletion packages/gems/js/ext/js/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,16 @@
$objs << "bindgen/legacy/rb-js-abi-host.o"
$objs << "bindgen/legacy/rb-abi-guest.o"
end

component_type_obj = "$(srcdir)/bindgen/ext_component_type.o"

unless $static
# When building shared library, we need to link the component type object
# to the shared library instead of the main ruby executable.
$libs << component_type_obj
end

create_makefile("js") do |mk|
mk << "EXTRA_OBJS = $(srcdir)/bindgen/ext_component_type.o\n" if use_component_model
mk << "EXTRA_OBJS = #{component_type_obj}\n" if use_component_model
mk
end
5 changes: 5 additions & 0 deletions packages/gems/js/ext/js/witapi-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,15 @@ static inline void __wasm_call_ctors_if_needed(void) {
__wasm_call_ctors_done = true;
__wasm_call_ctors();

// Initialize VFS runtime if it's used
// NOTE: We don't use wasi-vfs for PIC build. Instead, we use
// Component Model-native wasi-virt.
# ifndef __PIC__
__attribute__((weak)) extern void __wasi_vfs_rt_init(void);
if (__wasi_vfs_rt_init) {
__wasi_vfs_rt_init();
}
# endif
}
}

Expand Down

0 comments on commit 3cd8627

Please sign in to comment.