Skip to content

Commit 642625e

Browse files
committed
postgresql: Fix PostGIS cross-compilation for non-x64 architectures
- Restore GEOS 3.12.3 (was downgraded to 3.9.6 causing ARMv7 ODR violations) - Add pg_config wrapper for cross-compilation paths - Fix PostGIS configure libpq detection with sed patch - Exclude comcerto2k (GCC 4.9.3 lacks C++14 for GEOS 3.12.3) - Require DSM 7.0+ (GCC 4.9 strict linker fails libpq detection)
1 parent 0c829ee commit 642625e

7 files changed

Lines changed: 72 additions & 24 deletions

File tree

cross/libgeos/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@ HOMEPAGE = https://libgeos.org/
99
COMMENT = GEOS (Geometry Engine - Open Source) is a C/C++ library for computational geometry
1010
LICENSE = LGPL-2.1
1111

12+
# Disable tests to avoid cross-compilation issues and speed up build
13+
CMAKE_ARGS = -DBUILD_TESTING=OFF
14+
1215
# GEOS uses CMake
1316
include ../../mk/spksrc.cross-cmake.mk

cross/libproj/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ PKG_DIST_SITE = https://download.osgeo.org/proj
66
PKG_DIR = proj-$(PKG_VERS)
77

88
DEPENDS = cross/sqlite cross/libtiff cross/curl
9+
BUILD_DEPENDS = native/sqlite
910

1011
HOMEPAGE = https://proj.org/
1112
COMMENT = PROJ is a generic coordinate transformation software
1213
LICENSE = MIT
1314

1415
# PROJ uses CMake
16+
NATIVE_SQLITE_DIR = $(realpath $(WORK_DIR)/../../../native/sqlite/work-native/install/usr/local)
1517
CMAKE_ARGS += -DBUILD_TESTING=OFF
1618
CMAKE_ARGS += -DENABLE_CURL=ON
1719
CMAKE_ARGS += -DENABLE_TIFF=ON
20+
CMAKE_ARGS += -DEXE_SQLITE3=$(NATIVE_SQLITE_DIR)/bin/sqlite3
1821

1922
include ../../mk/spksrc.cross-cmake.mk

cross/postgis/Makefile

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,42 +14,47 @@ LICENSE = GPLv2
1414

1515
GNU_CONFIGURE = 1
1616

17-
# Path to cross-compiled PostgreSQL
18-
CROSS_PG_CONFIG = $(STAGING_INSTALL_PREFIX)/bin/pg_config
17+
# Cross-compilation requires a pg_config wrapper that returns cross-compiled
18+
# paths for libraries but uses native PGXS for building
19+
PG_VERSION = 17.4
20+
PG_CONFIG_WRAPPER = $(WORK_DIR)/pg_config_wrapper
21+
NATIVE_PG_DIR = $(realpath $(WORK_DIR)/../../../native/postgresql/work-native/install/usr/local)
1922

20-
CONFIGURE_ARGS = --with-pgconfig=$(CROSS_PG_CONFIG)
23+
CONFIGURE_ARGS = --with-pgconfig=$(PG_CONFIG_WRAPPER)
2124
CONFIGURE_ARGS += --with-geosconfig=$(STAGING_INSTALL_PREFIX)/bin/geos-config
2225
CONFIGURE_ARGS += --with-projdir=$(STAGING_INSTALL_PREFIX)
23-
24-
# Provide PROJ version to avoid cross-compilation test failure
2526
CONFIGURE_ARGS += PROJ_VERSION=8.2.1
26-
2727
CONFIGURE_ARGS += --without-raster
2828
CONFIGURE_ARGS += --without-protobuf
2929
CONFIGURE_ARGS += --without-gui
3030
CONFIGURE_ARGS += --without-topology
31+
# SSL libraries needed for libpq link check
32+
CONFIGURE_ARGS += LIBS="-lssl -lcrypto -lpthread -lm"
3133

32-
# Disable parallel build to avoid race conditions in SQL file generation
33-
COMPILE_MAKE_OPTIONS = -j1
34+
# Disable parallel build (SQL file generation race conditions)
35+
# Override CC since PGXS hardcodes gcc
36+
COMPILE_MAKE_OPTIONS = -j1 CC="$(TC_PATH)$(TC_PREFIX)gcc"
3437

35-
# Override install to use a custom target that handles PGXS path issues
36-
# PostGIS uses PGXS which gets paths from pg_config. The cross-compiled
37-
# pg_config returns paths with INSTALL_DIR baked in (e.g., /workspace/.../install/var/packages/...)
38-
# Since these paths already contain the install directory, we use DESTDIR=""
39-
# and PostGIS will install directly to the correct staging location.
38+
PRE_CONFIGURE_TARGET = postgis_pre_configure
4039
INSTALL_TARGET = postgis_install
4140

4241
include ../../mk/spksrc.cross-cc.mk
4342

43+
.PHONY: postgis_pre_configure
44+
postgis_pre_configure:
45+
@# Fix PostGIS configure to preserve LIBS during libpq check
46+
sed -i 's/LIBS="$$PGSQL_FE_LDFLAGS"/LIBS="$$PGSQL_FE_LDFLAGS $$LIBS"/g' $(WORK_DIR)/$(PKG_DIR)/configure
47+
@# Create pg_config wrapper from template
48+
sed -e 's|@NATIVE_PG_DIR@|$(NATIVE_PG_DIR)|g' \
49+
-e 's|@PG_VERSION@|$(PG_VERSION)|g' \
50+
-e 's|@CROSS_PG_INCLUDEDIR@|$(STAGING_INSTALL_PREFIX)/include|g' \
51+
-e 's|@CROSS_PG_LIBDIR@|$(STAGING_INSTALL_PREFIX)/lib|g' \
52+
-e 's|@CROSS_PG_SHAREDIR@|$(STAGING_INSTALL_PREFIX)/share|g' \
53+
-e 's|@CROSS_PG_BINDIR@|$(STAGING_INSTALL_PREFIX)/bin|g' \
54+
-e 's|@CROSS_CC@|$(TC_PATH)$(TC_PREFIX)gcc|g' \
55+
$(CURDIR)/src/pg_config_wrapper.sh.in > $(PG_CONFIG_WRAPPER)
56+
chmod +x $(PG_CONFIG_WRAPPER)
57+
4458
.PHONY: postgis_install
4559
postgis_install:
46-
@echo "Installing PostGIS with custom target..."
4760
$(RUN) $(MAKE) install DESTDIR=""
48-
@# Verify PostGIS files were installed
49-
@PKGLIBDIR=$$($(CROSS_PG_CONFIG) --pkglibdir); \
50-
if [ -f "$$PKGLIBDIR/postgis-3.so" ]; then \
51-
echo "PostGIS installation verified: $$PKGLIBDIR/postgis-3.so"; \
52-
else \
53-
echo "ERROR: PostGIS shared library not found at $$PKGLIBDIR"; \
54-
exit 1; \
55-
fi
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
# pg_config wrapper for PostGIS cross-compilation
3+
# Returns cross-compiled paths for libraries, native PGXS for building
4+
NATIVE_PG="@NATIVE_PG_DIR@"
5+
case "$1" in
6+
--version) echo "PostgreSQL @PG_VERSION@" ;;
7+
--pgxs) echo "$NATIVE_PG/lib/postgresql/pgxs/src/makefiles/pgxs.mk" ;;
8+
--includedir|--pkgincludedir) echo "@CROSS_PG_INCLUDEDIR@" ;;
9+
--includedir-server) echo "@CROSS_PG_INCLUDEDIR@/server" ;;
10+
--libdir|--pkglibdir) echo "@CROSS_PG_LIBDIR@" ;;
11+
--sharedir) echo "@CROSS_PG_SHAREDIR@" ;;
12+
--bindir) echo "@CROSS_PG_BINDIR@" ;;
13+
--ldflags) echo "-L@CROSS_PG_LIBDIR@" ;;
14+
--libs) echo "-lpq -lssl -lcrypto -lpthread -lm" ;;
15+
--cc) echo "@CROSS_CC@" ;;
16+
*) "$NATIVE_PG/bin/pg_config" "$1" ;;
17+
esac

native/sqlite/Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
PKG_NAME = sqlite-autoconf
2+
PKG_VERS = 3420000
3+
PKG_EXT = tar.gz
4+
PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT)
5+
PKG_DIST_SITE = https://www.sqlite.org/2023
6+
PKG_DIR = $(PKG_NAME)-$(PKG_VERS)
7+
8+
HOMEPAGE = https://www.sqlite.org/
9+
COMMENT = Self-contained, serverless, zero-configuration, transactional SQL database engine.
10+
LICENSE = Public Domain
11+
12+
GNU_CONFIGURE = 1
13+
14+
include ../../mk/spksrc.native-cc.mk

native/sqlite/digests

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
sqlite-autoconf-3420000.tar.gz SHA1 036575929b174c1b829769255491ba2b32bda9ee
2+
sqlite-autoconf-3420000.tar.gz SHA256 7abcfd161c6e2742ca5c6c0895d1f853c940f203304a0b49da4e1eca5d088ca6
3+
sqlite-autoconf-3420000.tar.gz MD5 0c5a92bc51cf07cae45b4a1e94653dea

spk/postgresql/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ NO_SERVICE_SHORTCUT = 1
2222

2323
include ../../mk/spksrc.common.mk
2424

25-
# libicu dependency doesn't support these architectures
26-
UNSUPPORTED_ARCHS = $(ARMv5_ARCHS) $(OLD_PPC_ARCHS)
25+
# libicu dependency doesn't support ARMv5/OLD_PPC (no DSM 7.x toolchains)
26+
# comcerto2k: DSM 7.x toolchain uses GCC 4.9.3 (GEOS 3.12.3 requires C++14/GCC 5+)
27+
UNSUPPORTED_ARCHS = comcerto2k
28+
# DSM < 7.0: GCC 4.9 fails PostGIS libpq detection (strict linker requires SSL libs)
29+
REQUIRED_MIN_DSM = 7.0
2730

2831
# Use auto-generated service user (sc-postgresql)
2932
SERVICE_USER = auto

0 commit comments

Comments
 (0)