Skip to content
Open
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
20 changes: 19 additions & 1 deletion src/backend/replication/pgoutput/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,27 @@ include $(top_srcdir)/src/Makefile.shlib

install: all installdirs install-lib

ifeq ($(PORTNAME), emscripten)
# pgoutput.so is loaded at runtime as an emscripten side module, but unlike
# pgxs-built extensions it is linked from src/backend, so its imports from the
# core module are not collected automatically. Without this, symbols used only
# by pgoutput (e.g. logicalrep_write_*) are dead-code-eliminated from the main
# module (-sMAIN_MODULE=2) and logical decoding fails at runtime with a call
# to an undefined table entry. Generate the .imports file here so the
# pglite-exported-functions target keeps these symbols alive.
install: install-imports

.PHONY: install-imports
install-imports: all
$(MKDIR_P) '$(DESTDIR)$(emscripten_extension_imports_dir)'
find . -name "*.o" -exec $(LLVM_NM) --undefined-only {} \; | awk '{print $$2}' | sed '/^$$/d' | sort -u > '$(NAME).undef.txt'
find . -type f \( -name "*.o" -o -name "*.so" \) -exec $(LLVM_NM) --defined-only {} \; | awk '$$2 ~ /^[TDB]$$/ {print $$3}' | sed '/^$$/d' | sort -u > '$(NAME).defs.txt'
comm -23 '$(NAME).undef.txt' '$(NAME).defs.txt' > '$(DESTDIR)$(emscripten_extension_imports_dir)/$(NAME).imports'
endif

installdirs: installdirs-lib

uninstall: uninstall-lib

clean distclean: clean-lib
rm -f $(OBJS)
rm -f $(OBJS) $(NAME).undef.txt $(NAME).defs.txt