Skip to content
Draft
Show file tree
Hide file tree
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
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ WASI_SDK_PATH := /opt/wasi-sdk
# the rest of the C API along with the wasi-libc code reachable from it.
WASM_EXPORTS := -Wl,--export=malloc,--export=free,--export=pm_buffer_new,--export=pm_buffer_value,--export=pm_buffer_length,--export=pm_buffer_free,--export=pm_serialize_parse

# Bind the library's own references to its own definitions at link time, so
# that the functions exported for FFI cannot be interposed by another copy of
# libprism loaded in the same process (for example the copy built into the
# interpreter next to the one built by a prism gem, when either copy was loaded
# with RTLD_GLOBAL). Mach-O and PE do this by default; only ELF needs the flag.
ifeq ($(SOEXT),so)
SHARED_LDFLAGS := -Wl,-Bsymbolic
endif

MAKEDIRS ?= mkdir -p
RMALL ?= rm -f -r

Expand All @@ -41,7 +50,7 @@ playground: doc/playground

build/libprism.$(SOEXT): $(SHARED_OBJECTS)
$(ECHO) "linking $@ with $(CC)"
$(Q) $(CC) $(DEBUG_FLAGS) $(CFLAGS) -shared -o $@ $(SHARED_OBJECTS)
$(Q) $(CC) $(DEBUG_FLAGS) $(CFLAGS) -shared $(SHARED_LDFLAGS) -o $@ $(SHARED_OBJECTS)

build/libprism.a: $(STATIC_OBJECTS)
$(ECHO) "building $@ with $(AR)"
Expand Down
1 change: 1 addition & 0 deletions docs/build_system.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ If you want to build prism as a shared library and link against it, you should c

* `-fPIC -shared` - Compile as a shared library
* `-DPRISM_EXPORT_SYMBOLS` - Export the symbols (by default nothing is exported)
* `-Wl,-Bsymbolic` (ELF platforms) - Bind the library's internal calls to its own exported functions at link time, so that they cannot be redirected to another copy of libprism loaded in the same process

#### Flags

Expand Down
Loading