From d1942b76a5dfa99cc10ec17b43e19f4992ca0366 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Thu, 24 Sep 2026 06:42:35 +0000 Subject: [PATCH 1/4] port: add riscv64 wheel build for pgserver 0.1.4 pgserver bundles a self-contained postgres server, compiling PostgreSQL 16.2 and the pgvector 0.6.2 extension from source via its own Makefile (cibuildwheel before-all = "make"), not a vendored prebuilt binary. Neither PostgreSQL's spinlock/atomics fallback (generic gcc __sync builtins) nor pgvector 0.6.2 (no SIMD dispatch at this version) gate on architecture, so this is an ordinary build-from-checkout port mirroring upstream's own manylinux cibuildwheel job. --- .github/workflows/build-pgserver.yml | 105 +++++++++++++++++++++++++++ docs/packages/pgserver.yaml | 5 ++ 2 files changed, 110 insertions(+) create mode 100644 .github/workflows/build-pgserver.yml create mode 100644 docs/packages/pgserver.yaml diff --git a/.github/workflows/build-pgserver.yml b/.github/workflows/build-pgserver.yml new file mode 100644 index 00000000000..a4a30ff9a02 --- /dev/null +++ b/.github/workflows/build-pgserver.yml @@ -0,0 +1,105 @@ +# SPDX-FileCopyrightText: 2026 The RISE Project +# SPDX-License-Identifier: MIT +--- +# This workflow is based on the `build_wheels` job of +# https://github.com/orm011/pgserver/blob/v0.1.4/.github/workflows/build-and-test.yml +name: Build pgserver wheels (riscv64) + +on: + workflow_dispatch: + inputs: + version: + description: 'Version glob to (re)build; empty builds every version of docs/packages/pgserver.yaml not released yet' + required: false + default: '' + pull_request: + branches: [main] + paths: + - '.github/workflows/build-pgserver.yml' + - 'docs/packages/pgserver.yaml' + push: + branches: [main] + paths: + - '.github/workflows/build-pgserver.yml' + - 'docs/packages/pgserver.yaml' + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read # to fetch code (actions/checkout) + +env: + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 + +jobs: + setup: + uses: $/.github/workflows/_setup.yml + with: + package: pgserver + version: ${{ inputs.version }} + + build_wheels: + needs: [setup] + if: needs.setup.outputs.versions != '[]' + name: Build pgserver ${{ matrix.version }} ${{ matrix.python }}-manylinux_riscv64 + runs-on: ubuntu-24.04-riscv + timeout-minutes: 180 + strategy: + fail-fast: false + matrix: + version: ${{ fromJSON(needs.setup.outputs.versions) }} + python: ["cp312", "cp313", "cp314", "cp314t"] + + env: + PGSERVER_VERSION: ${{ matrix.version }} + + steps: + - name: Checkout pgserver v${{ env.PGSERVER_VERSION }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: orm011/pgserver + ref: v${{ env.PGSERVER_VERSION }} + persist-credentials: false + + - name: Build wheels + uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 + with: + output-dir: wheelhouse/ + only: ${{ matrix.python }}-manylinux_riscv64 + env: + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} + CIBW_ENVIRONMENT: PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ + + - name: Verify the wheel ships the compiled postgres server and pgvector + run: | + python3 - wheelhouse/*.whl <<'EOF' + import sys, zipfile + names = zipfile.ZipFile(sys.argv[1]).namelist() + assert any(n.endswith("pgserver/pginstall/bin/postgres") for n in names), names + assert any(n.endswith("pgserver/pginstall/lib/postgresql/vector.so") for n in names), names + EOF + + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: pgserver-${{ env.PGSERVER_VERSION }}-${{ matrix.python }}-manylinux_riscv64 + path: wheelhouse/*.whl + if-no-files-found: error + + publish: + name: Publish pgserver ${{ matrix.version }} + needs: [setup, build_wheels] + if: needs.setup.outputs.versions != '[]' + strategy: + fail-fast: false + matrix: + version: ${{ fromJSON(needs.setup.outputs.versions) }} + permissions: + contents: write + pull-requests: write + uses: $/.github/workflows/_publish-wheel.yml + secrets: + app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }} + with: + artifact-pattern: pgserver-${{ matrix.version }}-*-manylinux_riscv64 diff --git a/docs/packages/pgserver.yaml b/docs/packages/pgserver.yaml new file mode 100644 index 00000000000..464c5fbb76d --- /dev/null +++ b/docs/packages/pgserver.yaml @@ -0,0 +1,5 @@ +package-name: pgserver +source-code: https://github.com/orm011/pgserver +license: Apache-2.0 +versions: +- version: 0.1.4 From a1c86b5d291404bc7e28aae0e63608739df1a83b Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Thu, 24 Sep 2026 06:45:24 +0000 Subject: [PATCH 2/4] port: ship postgresql/pgvector license texts in the pgserver wheel Add 0001-Add-LICENSE.postgresql-and-LICENSE.pgvector-matching.patch: the checkout carries no license text for the PostgreSQL or pgvector sources it compiles and bundles into every wheel, so neither reaches dist-info/licenses/. Apply it before the build and assert both land in the wheel alongside pgserver's own LICENSE. --- .github/workflows/build-pgserver.yml | 14 ++- ...gresql-and-LICENSE.pgvector-matching.patch | 87 +++++++++++++++++++ 2 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 patches/pgserver/0.1.4/0001-Add-LICENSE.postgresql-and-LICENSE.pgvector-matching.patch diff --git a/.github/workflows/build-pgserver.yml b/.github/workflows/build-pgserver.yml index a4a30ff9a02..ab0497e50ce 100644 --- a/.github/workflows/build-pgserver.yml +++ b/.github/workflows/build-pgserver.yml @@ -63,6 +63,15 @@ jobs: ref: v${{ env.PGSERVER_VERSION }} persist-credentials: false + - name: Checkout python-wheels + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + path: python-wheels + persist-credentials: false + + - name: Patch pgserver source + run: git apply python-wheels/patches/pgserver/${{ env.PGSERVER_VERSION }}/00*.patch + - name: Build wheels uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 with: @@ -72,13 +81,16 @@ jobs: CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} CIBW_ENVIRONMENT: PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ - - name: Verify the wheel ships the compiled postgres server and pgvector + - name: Verify the wheel ships the compiled postgres server, pgvector and their licences run: | python3 - wheelhouse/*.whl <<'EOF' import sys, zipfile names = zipfile.ZipFile(sys.argv[1]).namelist() assert any(n.endswith("pgserver/pginstall/bin/postgres") for n in names), names assert any(n.endswith("pgserver/pginstall/lib/postgresql/vector.so") for n in names), names + + lic = {n.split("/")[-1] for n in names if ".dist-info/licenses/" in n and not n.endswith("/")} + assert {"LICENSE", "LICENSE.postgresql", "LICENSE.pgvector"} <= lic, lic EOF - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 diff --git a/patches/pgserver/0.1.4/0001-Add-LICENSE.postgresql-and-LICENSE.pgvector-matching.patch b/patches/pgserver/0.1.4/0001-Add-LICENSE.postgresql-and-LICENSE.pgvector-matching.patch new file mode 100644 index 00000000000..00622400a41 --- /dev/null +++ b/patches/pgserver/0.1.4/0001-Add-LICENSE.postgresql-and-LICENSE.pgvector-matching.patch @@ -0,0 +1,87 @@ +From cc565ab3bc1da7a419e3d5d50f2fa1f6742fcd4f Mon Sep 17 00:00:00 2001 +From: Ludovic Henry +Date: Thu, 24 Sep 2026 06:44:17 +0000 +Subject: [PATCH] Add LICENSE.postgresql and LICENSE.pgvector matching + setuptools' default glob + +setup.py declares no explicit license_files, so setuptools' default +LICEN[CS]E*/COPYING*/NOTICE*/AUTHORS* glob applies at the project root +only. pgserver's build compiles PostgreSQL 16.2 and the pgvector 0.6.2 +extension from source (pgbuild/Makefile, fetched at build time from +ftp.postgresql.org and github.com/pgvector/pgvector) and bundles the +resulting binaries and libraries into every wheel, but the checkout +carries no license text for either project, so neither one lands in +dist-info/licenses/ even though their compiled code ships in every +wheel. + +Add a copy of each project's own license text at the root as +LICENSE.postgresql and LICENSE.pgvector, which the existing default +glob already matches with no setup.py/pyproject.toml change. Both are +the permissive, non-copyleft PostgreSQL License. + +Upstream-Status: To upstream [not submitted from this automated port run; needs a pull request against orm011/pgserver] +--- + LICENSE.pgvector | 20 ++++++++++++++++++++ + LICENSE.postgresql | 23 +++++++++++++++++++++++ + 2 files changed, 43 insertions(+) + create mode 100644 LICENSE.pgvector + create mode 100644 LICENSE.postgresql + +diff --git a/LICENSE.pgvector b/LICENSE.pgvector +new file mode 100644 +index 0000000..066b96a +--- /dev/null ++++ b/LICENSE.pgvector +@@ -0,0 +1,20 @@ ++Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group ++ ++Portions Copyright (c) 1994, The Regents of the University of California ++ ++Permission to use, copy, modify, and distribute this software and its ++documentation for any purpose, without fee, and without a written agreement ++is hereby granted, provided that the above copyright notice and this ++paragraph and the following two paragraphs appear in all copies. ++ ++IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR ++DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING ++LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS ++DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE ++POSSIBILITY OF SUCH DAMAGE. ++ ++THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, ++INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY ++AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ++ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO ++PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. +diff --git a/LICENSE.postgresql b/LICENSE.postgresql +new file mode 100644 +index 0000000..16f9b46 +--- /dev/null ++++ b/LICENSE.postgresql +@@ -0,0 +1,23 @@ ++PostgreSQL Database Management System ++(formerly known as Postgres, then as Postgres95) ++ ++Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group ++ ++Portions Copyright (c) 1994, The Regents of the University of California ++ ++Permission to use, copy, modify, and distribute this software and its ++documentation for any purpose, without fee, and without a written agreement ++is hereby granted, provided that the above copyright notice and this ++paragraph and the following two paragraphs appear in all copies. ++ ++IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR ++DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING ++LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS ++DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE ++POSSIBILITY OF SUCH DAMAGE. ++ ++THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, ++INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY ++AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ++ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO ++PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. +-- +2.43.0 + From c8475c89861ad6ef937e8ffa801eb5c759c39e65 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Thu, 24 Sep 2026 11:36:32 +0000 Subject: [PATCH 3/4] fix: don't pass -march=native into the vendored pgvector build (riscv64) All four riscv64 build legs failed identically after 30+ minutes, partway through compiling pgvector (fetched and built by pgserver's own pgbuild/Makefile): GCC on manylinux_2_39_riscv64 rejects `-march=native` outright ("ISA string must begin with rv32 or rv64"), which pgvector's Makefile passes unconditionally except for Mac ARM and ppc64. Add patches/pgserver/0.1.4/0002-*.patch, overriding OPTFLAGS to empty on the pgbuild/Makefile invocations that build pgvector, the same way pgvector's own Makefile already blanks it for architectures that reject -march=native. Verified the patch applies cleanly (alone and together with the existing 0001 licensing patch) against a fresh v0.1.4 checkout. check_commit_messages was failing on an older run (35966092162) but passes on the current HEAD's latest run; no commit-message change needed. --- ...s-march-native-to-the-pgvector-build.patch | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 patches/pgserver/0.1.4/0002-Do-not-pass-march-native-to-the-pgvector-build.patch diff --git a/patches/pgserver/0.1.4/0002-Do-not-pass-march-native-to-the-pgvector-build.patch b/patches/pgserver/0.1.4/0002-Do-not-pass-march-native-to-the-pgvector-build.patch new file mode 100644 index 00000000000..f4df50c8ace --- /dev/null +++ b/patches/pgserver/0.1.4/0002-Do-not-pass-march-native-to-the-pgvector-build.patch @@ -0,0 +1,46 @@ +From 728980fe6d03379af74d1bb4f04fab977d5039d9 Mon Sep 17 00:00:00 2001 +From: Ludovic Henry +Date: Thu, 24 Sep 2026 11:26:36 +0000 +Subject: [PATCH] Do not pass -march=native to the pgvector build + +pgvector's Makefile sets `OPTFLAGS = -march=native` unconditionally, +with hand-written exceptions only for Mac ARM and ppc64 (neither of +which supports -march=native either). On the manylinux_riscv64 +(quay.io/pypa/manylinux_2_39_riscv64) image, GCC's -march=native +self-detection produces an empty/invalid ISA string on riscv64 and +the build fails outright: + + gcc: error: '-march=native': ISA string must begin with rv32 or rv64 + +pgvector is fetched and built by pgserver's own pgbuild/Makefile at +build time (not vendored in this checkout), so the fix lives here +rather than as a patch to a downloaded tarball: override OPTFLAGS to +empty on the two `make -C $(PGVECTOR_DIR)` invocations, the same way +pgvector's own Makefile already blanks OPTFLAGS for architectures +that reject -march=native. pgvector still gets the auto-vectorization +flags (-ftree-vectorize etc.) at the baseline rv64gc ISA; only the +native/RVV-specific tuning is dropped. + +Upstream-Status: Inappropriate [riscv64/CI-infra-specific override of a downstream build script; pgvector's own -march=native default is correct for every architecture it targets] +--- + pgbuild/Makefile | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/pgbuild/Makefile b/pgbuild/Makefile +index d6f8b13..f9ecbb4 100644 +--- a/pgbuild/Makefile ++++ b/pgbuild/Makefile +@@ -55,8 +55,8 @@ $(PGVECTOR_DIR)/Makefile: $(PGVECTOR_DIR).tar.gz + $(INSTALL_PREFIX)/lib/vector.so: $(PGVECTOR_DIR)/Makefile $(INSTALL_PREFIX)/bin/postgres + unset MAKELEVEL && unset MAKEFLAGS && unset MFLAGS \ + && export PG_CONFIG=$(INSTALL_PREFIX)/bin/pg_config \ +- && $(MAKE) -C $(PGVECTOR_DIR) -j \ +- && $(MAKE) -C $(PGVECTOR_DIR) install ++ && $(MAKE) -C $(PGVECTOR_DIR) -j OPTFLAGS= \ ++ && $(MAKE) -C $(PGVECTOR_DIR) install OPTFLAGS= + + .PHONY: pgvector + pgvector: postgres $(INSTALL_PREFIX)/lib/vector.so +-- +2.43.0 + From bd1c81a6613ec190b4989eeec2231ac174f70963 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Thu, 24 Sep 2026 16:48:11 +0000 Subject: [PATCH 4/4] pgserver: bound the test-phase hang after a segfaulting initdb cp312/cp313/cp314 all reproduced the same crash identically across three independent riscv64 runners: pgserver's from-source-built initdb dies with SIGSEGV on its very first invocation (test_get_server), and on every invocation after. That is real and, without riscv64 hardware to debug interactively, unresolved (documented as gotcha 564 in a follow-up bookkeeping commit to main) - configure correctly detects native __sync/__atomic builtins and the build passes no aggressive flags, so it isn't an obvious atomics-fallback or -march problem. What's actionable now: test_reuse_deleted_datadir_short starts a server in a multiprocessing.Process and then blocks on queue.get() with no timeout; when the child dies from the initdb segfault it never puts anything on the queue, so the parent (and the whole job) hangs until the workflow's 180-minute timeout kills it - a full runner-hour cycle spent confirming a crash pytest had already reported seconds in. Bound it from the workflow side (gotcha 563): CIBW_TEST_REQUIRES: pytest-timeout plus PYTEST_ADDOPTS="--timeout=300" folded into the existing CIBW_ENVIRONMENT line, which cibuildwheel applies to both the build and test phases. No patch to pgserver's own source needed - its test-command has no room to pass extra pytest flags, but CIBW_ENVIRONMENT reaches it anyway. --- .github/workflows/build-pgserver.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-pgserver.yml b/.github/workflows/build-pgserver.yml index ab0497e50ce..3bce493986d 100644 --- a/.github/workflows/build-pgserver.yml +++ b/.github/workflows/build-pgserver.yml @@ -79,7 +79,9 @@ jobs: only: ${{ matrix.python }}-manylinux_riscv64 env: CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} - CIBW_ENVIRONMENT: PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ + CIBW_ENVIRONMENT: PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ PYTEST_ADDOPTS="--timeout=300" + # gotcha 563/564: bounds a crashed initdb (riscv64-only, unresolved) to a fast per-test failure instead of a 180-minute hang. + CIBW_TEST_REQUIRES: pytest-timeout - name: Verify the wheel ships the compiled postgres server, pgvector and their licences run: |