Skip to content

Commit 7fb4e61

Browse files
committed
fix(ci): add -undefined dynamic_lookup for macOS PostgreSQL extension linking
macOS linker requires explicit handling of undefined symbols. PostgreSQL extensions resolve symbols at load time, so -undefined dynamic_lookup is needed. Also consolidate UNAME_S detection to a single location.
1 parent 5037e0e commit 7fb4e61

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

docker/Makefile.postgresql

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ PG_INCLUDEDIR := $(shell $(PG_CONFIG) --includedir-server 2>/dev/null)
1414
EXTENSION = cloudsync
1515
EXTVERSION = 1.0
1616

17+
# Detect OS for platform-specific settings
18+
ifneq ($(OS),Windows_NT)
19+
UNAME_S := $(shell uname -s)
20+
endif
21+
1722
# Platform-specific PostgreSQL settings
1823
ifeq ($(OS),Windows_NT)
1924
PG_EXTENSION_LIB = $(EXTENSION).dll
@@ -22,7 +27,12 @@ ifeq ($(OS),Windows_NT)
2227
else
2328
PG_EXTENSION_LIB = $(EXTENSION).so
2429
PG_CFLAGS = -fPIC -Wall -Wextra -Wno-unused-parameter -std=c11 -O2
25-
PG_LDFLAGS = -shared
30+
ifeq ($(UNAME_S),Darwin)
31+
# macOS: allow undefined symbols resolved at load time by PostgreSQL
32+
PG_LDFLAGS = -shared -undefined dynamic_lookup
33+
else
34+
PG_LDFLAGS = -shared
35+
endif
2636
endif
2737

2838
# Source files - core platform-agnostic code
@@ -53,7 +63,6 @@ PG_EXTRA_CFLAGS ?=
5363
PG_CPPFLAGS = -I$(PG_INCLUDEDIR) -Isrc -Isrc/postgresql -Imodules/fractional-indexing -DCLOUDSYNC_POSTGRESQL_BUILD $(PG_EXTRA_CFLAGS)
5464
ifneq ($(OS),Windows_NT)
5565
PG_CPPFLAGS += -D_POSIX_C_SOURCE=200809L
56-
UNAME_S := $(shell uname -s)
5766
ifeq ($(UNAME_S),Darwin)
5867
PG_CPPFLAGS += -D_DARWIN_C_SOURCE
5968
else

0 commit comments

Comments
 (0)