From 29367ddc27a908f7b59d4e871ccfa50dd0753007 Mon Sep 17 00:00:00 2001 From: Alex Kasko Date: Sat, 18 Apr 2026 17:24:46 +0100 Subject: [PATCH] Update libpq to 18.3 --- .github/workflows/IntegrationTests.yml | 1 + .../workflows/MainDistributionPipeline.yml | 6 - concurrency_test.cpp | 231 ---------- include/pg_config_paths.h | 1 - vcpkg_ports/libpq/Makefile | 5 +- .../libpq/android/unversioned_so.patch | 16 - vcpkg_ports/libpq/build-msvc.cmake | 273 +++++++++--- vcpkg_ports/libpq/portfile.cmake | 67 ++- vcpkg_ports/libpq/unix/fix-configure.patch | 59 +-- vcpkg_ports/libpq/unix/installdirs.patch | 18 +- .../unix/mingw-static-importlib-fix.patch | 64 +++ vcpkg_ports/libpq/unix/no-server-tools.patch | 4 +- vcpkg_ports/libpq/unix/single-linkage.patch | 4 +- vcpkg_ports/libpq/vcpkg.json | 5 +- vcpkg_ports/libpq/windows/getopt.patch | 21 + vcpkg_ports/libpq/windows/macro-def.patch | 2 +- vcpkg_ports/libpq/windows/meson-vcpkg.patch | 45 ++ vcpkg_ports/libpq/windows/msbuild.patch | 398 ------------------ .../libpq/windows/win_bison_flex.patch | 42 -- 19 files changed, 410 insertions(+), 852 deletions(-) delete mode 100644 concurrency_test.cpp delete mode 100644 include/pg_config_paths.h delete mode 100644 vcpkg_ports/libpq/android/unversioned_so.patch create mode 100644 vcpkg_ports/libpq/unix/mingw-static-importlib-fix.patch create mode 100644 vcpkg_ports/libpq/windows/getopt.patch create mode 100644 vcpkg_ports/libpq/windows/meson-vcpkg.patch delete mode 100644 vcpkg_ports/libpq/windows/msbuild.patch delete mode 100644 vcpkg_ports/libpq/windows/win_bison_flex.patch diff --git a/.github/workflows/IntegrationTests.yml b/.github/workflows/IntegrationTests.yml index 4f8f8dc5b..31e03b583 100644 --- a/.github/workflows/IntegrationTests.yml +++ b/.github/workflows/IntegrationTests.yml @@ -7,6 +7,7 @@ on: - '!.github/workflows/IntegrationTests.yml' pull_request: repository_dispatch: + workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || '' }}-${{ github.base_ref || '' }}-${{ github.ref != 'refs/heads/main' || github.sha }} cancel-in-progress: true diff --git a/.github/workflows/MainDistributionPipeline.yml b/.github/workflows/MainDistributionPipeline.yml index b38d815c9..0bed21849 100644 --- a/.github/workflows/MainDistributionPipeline.yml +++ b/.github/workflows/MainDistributionPipeline.yml @@ -3,12 +3,6 @@ # name: Main Extension Distribution Pipeline on: - push: - paths-ignore: - - '**.md' - - '.github/workflows/**' - - '!.github/workflows/MainDistributionPipeline.yml' - pull_request: workflow_dispatch: concurrency: diff --git a/concurrency_test.cpp b/concurrency_test.cpp deleted file mode 100644 index 2ddc12ce0..000000000 --- a/concurrency_test.cpp +++ /dev/null @@ -1,231 +0,0 @@ -#include "duckdb.hpp" -#include -#include -#include -#include - -std::random_device rd; // only used once to initialise (seed) engine -std::mt19937 rng(rd()); // random-number engine used (Mersenne-Twister in this case) - -using namespace duckdb; - -struct PostgresResult { - ~PostgresResult() { - if (res) { - PQclear(res); - } - } - PGresult *res = nullptr; - - string GetString(idx_t row, idx_t col) { - D_ASSERT(res); - return string(PQgetvalue(res, row, col)); - } - - int32_t GetInt32(idx_t row, idx_t col) { - return atoi(PQgetvalue(res, row, col)); - } - int64_t GetInt64(idx_t row, idx_t col) { - return atoll(PQgetvalue(res, row, col)); - } -}; - -static void PGExec(PGconn *conn, string q) { - auto res = make_uniq(); - res->res = PQexec(conn, q.c_str()); - - if (!res->res) { - throw IOException("Unable to query Postgres"); - } - if (PQresultStatus(res->res) != PGRES_COMMAND_OK) { - throw IOException("Unable to query Postgres: %s", string(PQresultErrorMessage(res->res))); - } -} - -static unique_ptr PGQuery(PGconn *conn, string q) { - auto res = make_uniq(); - res->res = PQexec(conn, q.c_str()); - - if (!res->res) { - throw IOException("Unable to query Postgres"); - } - if (PQresultStatus(res->res) != PGRES_TUPLES_OK) { - throw IOException("Unable to query Postgres: %s", string(PQresultErrorMessage(res->res))); - } - return res; -} - -static DuckDB db; - -static string CHECKQ = "SELECT SUM(val), COUNT(val) FROM series"; -static uint64_t INVARIANT = 42000000; -static uint64_t THREADS = 4; - -static const char *DSN = ""; - -static bool carry_on = true; - -void ptask(idx_t i) { - idx_t n = 0; - std::uniform_int_distribution ids_rng(1, 1000000); // guaranteed unbiased - std::uniform_int_distribution amount_rng(1, 100); // guaranteed unbiased - - auto pconn = PQconnectdb(DSN); - - if (PQstatus(pconn) == CONNECTION_BAD) { - throw IOException("Unable to connect to Postgres at %s", DSN); - } - - while (carry_on) { - auto source = ids_rng(rng); - auto target = ids_rng(rng); - auto amount = amount_rng(rng); - - /* Multiple queries sent in a single PQexec call are processed in a single - * transaction, unless there are explicit BEGIN/COMMIT commands included in - * the query string to divide it into multiple transactions. */ - PGExec(pconn, StringUtil::Format(R"( -UPDATE series SET val = val - %d WHERE id=%d; -UPDATE series SET val = val + %d WHERE id=%d; - )", - amount, source, amount, target)); - - n++; - } - - PQfinish(pconn); - printf("ptask %llu done %llu\n", i, n); -} - -void ctask(idx_t sleep_ms) { - idx_t n = 0; - auto pconn = PQconnectdb(DSN); - - if (PQstatus(pconn) == CONNECTION_BAD) { - throw IOException("Unable to connect to Postgres at %s", DSN); - } - - while (carry_on) { - PGExec(pconn, "CHECKPOINT"); - std::this_thread::sleep_for(std::chrono::milliseconds(sleep_ms)); - - n++; - } - PQfinish(pconn); - printf("ctask done %llu\n", n); -} - -void pctask() { - idx_t failure = 0; - idx_t n = 0; - auto pconn = PQconnectdb(DSN); - - while (carry_on) { - - auto pres = PGQuery(pconn, CHECKQ); - if (pres->GetInt64(0, 0) != INVARIANT) { - InternalException("Invariant fail"); - } - pres.reset(); - n++; - } - PQfinish(pconn); - - printf("pctask done %llu, inconsistent %llu\n", n, failure); -} - -void dtask() { - idx_t failure = 0; - - idx_t n = 0; - Connection dconn(db); - - while (carry_on) { - - auto dres = dconn.Query(CHECKQ); - if (!dres->success) { - throw InternalException(dres->error); - } - auto val = dres->GetValue(0, 0).GetValue(); - if (val != INVARIANT) { - failure++; - printf("Invariant fail : %llu %llu\n", val, dres->GetValue(1, 0).GetValue()); - } - n++; - } - - printf("dtask done %llu, inconsistent %llu\n", n, failure); -} - -void ttask(idx_t n) { - std::this_thread::sleep_for(std::chrono::milliseconds(n)); - carry_on = false; -} - -int main() { - auto pconn = PQconnectdb(DSN); - - if (PQstatus(pconn) == CONNECTION_BAD) { - throw IOException("Unable to connect to Postgres at %s", DSN); - } - PGExec(pconn, "DROP TABLE IF EXISTS series"); - PGExec(pconn, "CREATE TABLE series AS select * from generate_series (1, " - "1000000) id, LATERAL (SELECT 42 val) sq"); - PGExec(pconn, "CREATE INDEX series_pk ON series (id)"); - PGExec(pconn, "CHECKPOINT"); - - // query the table schema so we can interpret the bits in the pages - // fun fact: this query also works in DuckDB ^^ - auto pres = PGQuery(pconn, CHECKQ); - if (pres->GetInt64(0, 0) != INVARIANT) { - InternalException("Invariant fail"); - } - pres.reset(); - PQfinish(pconn); - - Connection dconn(db); - auto dres = dconn.Query("LOAD 'build/release/postgres_scanner.duckdb_extension'"); - if (!dres->success) { - throw InternalException(dres->error); - } - dres = dconn.Query("CALL postgres_attach('')"); - if (!dres->success) { - throw InternalException(dres->error); - } - dres = dconn.Query(CHECKQ); - if (!dres->success) { - throw InternalException(dres->error); - } - auto val = dres->GetValue(0, 0).GetValue(); - if (val != INVARIANT) { - printf("Initial Invariant fail : %llu %llu\n", val, dres->GetValue(1, 0).GetValue()); - } - - // battle plan: launch n threads, have them loop transactions that move val - // around between random ids launch another thread that loops the duckdb query - - std::thread d1(dtask); - std::thread pc1(pctask); - - std::thread t1(ttask, 10000); - std::thread c1(ctask, 500); - - vector pthreads(THREADS); - for (idx_t i = 0; i < THREADS; i++) { - pthreads[i] = new std::thread(ptask, i); - } - - for (idx_t i = 0; i < THREADS; i++) { - pthreads[i]->join(); - delete pthreads[i]; - } - - d1.join(); - pc1.join(); - - t1.join(); - c1.join(); - - printf("done\n"); - return 0; -} diff --git a/include/pg_config_paths.h b/include/pg_config_paths.h deleted file mode 100644 index c4838dc75..000000000 --- a/include/pg_config_paths.h +++ /dev/null @@ -1 +0,0 @@ -#define SYSCONFDIR "" \ No newline at end of file diff --git a/vcpkg_ports/libpq/Makefile b/vcpkg_ports/libpq/Makefile index 67994f4ba..d743b5335 100644 --- a/vcpkg_ports/libpq/Makefile +++ b/vcpkg_ports/libpq/Makefile @@ -23,6 +23,9 @@ all: $(MAKE) -C src/interfaces/ecpg/pgtypeslib $(MAKE) -C src/interfaces/ecpg/ecpglib $(MAKE) -C src/interfaces/ecpg/compatlib +ifeq ($(LIBPQ_LIBRARY_TYPE), static) + $(AR) $(AROPT) src/interfaces/libpq/libpq.a src/common/encnames_shlib.o +endif ifeq ($(LIBPQ_ENABLE_TOOLS), yes) $(MAKE) -C src/interfaces/ecpg/preproc $(MAKE) -C src/fe_utils @@ -34,7 +37,7 @@ endif .PHONY: install-stlib install-stlib: $(MAKE) -C src/common install -o all - rm -f '$(DESTDIR)$(libdir)/libpgcommon_shlib.a' + mv -f '$(DESTDIR)$(libdir)/libpgcommon_shlib.a' '$(DESTDIR)$(libdir)/libpgcommon.a' $(MAKE) -C src/port install -o all rm -f '$(DESTDIR)$(libdir)/libpgport_shlib.a' diff --git a/vcpkg_ports/libpq/android/unversioned_so.patch b/vcpkg_ports/libpq/android/unversioned_so.patch deleted file mode 100644 index 42096a367..000000000 --- a/vcpkg_ports/libpq/android/unversioned_so.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff --git a/src/Makefile.shlib b/src/Makefile.shlib -index f94d59d1c597..8ca51ca03f75 100644 ---- a/src/Makefile.shlib -+++ b/src/Makefile.shlib -@@ -183,6 +183,11 @@ endif - ifeq ($(PORTNAME), linux) - LINK.shared = $(COMPILER) -shared - ifdef soname -+ ifneq (,$(findstring linux-android,$(host_os))) -+ # Android uses unversioned shared libraries -+ shlib = $(shlib_bare) -+ soname = $(shlib_bare) -+ endif - LINK.shared += -Wl,-soname,$(soname) - endif - BUILD.exports = ( echo '{ global:'; $(AWK) '/^[^\#]/ {printf "%s;\n",$$1}' $<; echo ' local: *; };' ) >$@ diff --git a/vcpkg_ports/libpq/build-msvc.cmake b/vcpkg_ports/libpq/build-msvc.cmake index 34d969487..36dd79391 100644 --- a/vcpkg_ports/libpq/build-msvc.cmake +++ b/vcpkg_ports/libpq/build-msvc.cmake @@ -1,80 +1,221 @@ -function(build_msvc build_type source_path) - if(build_type STREQUAL "DEBUG") - set(vcpkg_configuration "Debug") - set(label "${TARGET_TRIPLET}-dbg") - set(packages_dir "${CURRENT_PACKAGES_DIR}/debug") - else() - set(vcpkg_configuration "Release") - set(label "${TARGET_TRIPLET}-rel") - set(packages_dir "${CURRENT_PACKAGES_DIR}") - endif() +function(build_msvc source_path) + # Strip meson build to only compile client libraries and tools. + # The full PostgreSQL meson build includes the server backend, timezone data, + # PL languages, contrib modules, and tests - none of which we need. + + # src/meson.build: keep only bin (client tools) and interfaces (ecpg) + file(WRITE "${source_path}/src/meson.build" [=[ +subdir('bin') +subdir('interfaces') +]=]) - set(build_path "${CURRENT_BUILDTREES_DIR}/${label}") - file(REMOVE_RECURSE "${build_path}") - file(COPY "${source_path}/" DESTINATION "${build_path}") + # src/bin/meson.build: only client tools (mirrors unix/no-server-tools.patch) + file(WRITE "${source_path}/src/bin/meson.build" [=[ +subdir('pg_amcheck') +subdir('pg_basebackup') +subdir('pg_config') +subdir('pg_dump') +subdir('pg_verifybackup') +subdir('pgbench') +subdir('pgevent') +subdir('psql') +subdir('scripts') +]=]) + # Truncate meson.build before the test/pseudo-target sections that reference + # variables from skipped subdirs (pg_regress, regress_module, docs, etc.). + # The subdirs themselves are already commented out by windows/meson-vcpkg.patch, + # but the test infrastructure section still references variables from them. + file(READ "${source_path}/meson.build" meson_content) + string(FIND "${meson_content}" "# all targets that require building code" truncate_pos) + if(NOT truncate_pos EQUAL -1) + string(SUBSTRING "${meson_content}" 0 ${truncate_pos} meson_content) + file(WRITE "${source_path}/meson.build" "${meson_content}") + endif() + + # For static builds, remove __declspec(dllimport) from installed headers if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") - vcpkg_replace_string("${build_path}/src/include/port/win32.h" "__declspec (dllimport)" "") + vcpkg_replace_string("${source_path}/src/include/port/win32.h" + "__declspec (dllimport)" "") endif() - vcpkg_replace_string("${build_path}/src/tools/msvc/MSBuildProject.pm" "perl " "\"${PERL}\" ") - configure_file("${CURRENT_PORT_DIR}/libpq.props.in" "${build_path}/libpq.props" @ONLY) - configure_file("${CURRENT_PORT_DIR}/vcpkg-libs.props.in" "${build_path}/vcpkg-libs.props" @ONLY) - set(config "# Generated by ${CMAKE_CURRENT_LIST_FILE}\n\n") - foreach(var IN ITEMS VCPKG_TARGET_ARCHITECTURE VCPKG_LIBRARY_LINKAGE VCPKG_CRT_LINKAGE) - string(APPEND config "\$config->{${var}} = \"${${var}}\";\n") - endforeach() - foreach(option IN ITEMS icu lz4 nls openssl python tcl xml xslt zlib zstd) + + # The meson build compiles the static pgcommon with -DUSE_PRIVATE_ENCODING_FUNCS, + # which renames pg_char_to_encoding -> pg_char_to_encoding_private. But libpq + # (compiled as FRONTEND without that flag) calls the non-private names, causing + # unresolved symbols for consumers. The autoconf Makefile works around this by + # installing pgcommon_shlib (non-private names) as pgcommon. Since we don't build + # the server backend, there's no symbol conflict risk, so just remove the flag. + vcpkg_replace_string("${source_path}/src/common/meson.build" + "'c_args': ['-DUSE_PRIVATE_ENCODING_FUNCS']," + "# 'c_args': ['-DUSE_PRIVATE_ENCODING_FUNCS'], # vcpkg: use non-private names") + + # Map vcpkg features to meson options + vcpkg_list(SET MESON_OPTIONS) + + # Disable auto-detection so we don't pick up random system libraries + list(APPEND MESON_OPTIONS -Dauto_features=disabled) + + # Features that map directly to meson option names + foreach(option IN ITEMS icu lz4 zlib zstd) if(option IN_LIST FEATURES) - string(APPEND config "\$config->{${option}} = \"${CURRENT_INSTALLED_DIR}\";\n") + list(APPEND MESON_OPTIONS -D${option}=enabled) endif() endforeach() + + # Features with different meson option names if("openssl" IN_LIST FEATURES) - file(STRINGS "${CURRENT_INSTALLED_DIR}/lib/pkgconfig/openssl.pc" OPENSSL_VERSION REGEX "Version:") - string(APPEND config "\$config->{openssl_version} = '${OPENSSL_VERSION}';\n") + list(APPEND MESON_OPTIONS -Dssl=openssl) + else() + list(APPEND MESON_OPTIONS -Dssl=none) + endif() + if("xml" IN_LIST FEATURES) + list(APPEND MESON_OPTIONS -Dlibxml=enabled) + endif() + if("xslt" IN_LIST FEATURES) + list(APPEND MESON_OPTIONS -Dlibxslt=enabled) + endif() + if("nls" IN_LIST FEATURES) + list(APPEND MESON_OPTIONS -Dnls=enabled) + # Static intl depends on iconv, but PostgreSQL's meson build uses + # cc.find_library('intl') which doesn't resolve transitive deps. + # Patch to also link iconv when intl is found. + vcpkg_replace_string("${source_path}/meson.build" + "i18n = import('i18n')" + "iconv_dep = cc.find_library('iconv', required: false, dirs: test_lib_d)\n if iconv_dep.found()\n libintl = declare_dependency(dependencies: [libintl, iconv_dep])\n endif\n i18n = import('i18n')") + endif() + # plpython requires matching debug/release Python libraries. + # vcpkg's Python is release-only, so only enable for release builds. + vcpkg_list(SET MESON_OPTIONS_RELEASE) + vcpkg_list(SET MESON_OPTIONS_DEBUG) + if("python" IN_LIST FEATURES) + if(VCPKG_CROSSCOMPILING) + # plpython can't be configured when cross-compiling because meson + # needs to run the Python interpreter at configure time, but the + # target binary won't execute on the build host. + message(STATUS "Disabling plpython for cross-compilation build") + list(APPEND MESON_OPTIONS -Dplpython=disabled) + else() + # Use the vcpkg python3 interpreter (which has matching dev libraries) + # instead of the standalone tools Python (which has no SDK). + string(REPLACE [[\]] [[/]] VCPKG_PYTHON3_PATH "${CURRENT_INSTALLED_DIR}/tools/python3/python.exe") + list(APPEND MESON_OPTIONS_RELEASE -Dplpython=enabled "-DPYTHON=${VCPKG_PYTHON3_PATH}") + list(APPEND MESON_OPTIONS_DEBUG -Dplpython=disabled) + endif() endif() - string(APPEND config "\$config->{python_version} = '3.${PYTHON_VERSION_MINOR}';\n") - string(APPEND config "\$config->{tcl_version} = '90';\n") - file(WRITE "${build_path}/src/tools/msvc/config.pl" "${config}") - - set(build_in_parallel "-m") - set(build_targets libpq libecpg_compat) - set(install_target core) - if(HAS_TOOLS AND NOT build_type STREQUAL "DEBUG") - set(build_in_parallel "") # mitigate winflex races - set(build_targets client) - set(install_target client) + if("tcl" IN_LIST FEATURES) + list(APPEND MESON_OPTIONS -Dpltcl=enabled) + # The vcpkg tcl port doesn't generate pkg-config files on Windows, + # so meson's dependency('tcl90') fails. Its fallback cc.find_library() + # also fails because meson's link-test probe doesn't work reliably + # with vcpkg's directory layout. Generate .pc files so meson can + # find Tcl through its preferred pkg-config path. + # Tcl naming: tcl90 (dynamic), tcl90s (static), +g suffix for debug. + set(_tcl_pc_name "tcl90") + # Determine the release library name + if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + set(_tcl_rel_libname "tcl90s") + else() + set(_tcl_rel_libname "tcl90") + endif() + # Generate release .pc file + set(_tcl_pc_dir "${CURRENT_INSTALLED_DIR}/lib/pkgconfig") + file(MAKE_DIRECTORY "${_tcl_pc_dir}") + file(WRITE "${_tcl_pc_dir}/${_tcl_pc_name}.pc" +"prefix=${CURRENT_INSTALLED_DIR}\nlibdir=\${prefix}/lib\nincludedir=\${prefix}/include\n\nName: ${_tcl_pc_name}\nDescription: Tcl scripting language\nVersion: 9.0\nLibs: -L\${libdir} -l${_tcl_rel_libname}\nCflags: -I\${includedir}\n") + # Determine the debug library name + if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + set(_tcl_dbg_libname "tcl90sg") + else() + set(_tcl_dbg_libname "tcl90g") + endif() + # Generate debug .pc file + if(NOT VCPKG_BUILD_TYPE) + set(_tcl_pc_dbg_dir "${CURRENT_INSTALLED_DIR}/debug/lib/pkgconfig") + file(MAKE_DIRECTORY "${_tcl_pc_dbg_dir}") + file(WRITE "${_tcl_pc_dbg_dir}/${_tcl_pc_name}.pc" +"prefix=${CURRENT_INSTALLED_DIR}/debug\nlibdir=\${prefix}/lib\nincludedir=${CURRENT_INSTALLED_DIR}/include\n\nName: ${_tcl_pc_name}\nDescription: Tcl scripting language\nVersion: 9.0\nLibs: -L\${libdir} -l${_tcl_dbg_libname}\nCflags: -I\${includedir}\n") + endif() + list(APPEND MESON_OPTIONS "-Dtcl_version=${_tcl_pc_name}") endif() - string(REPLACE "x86" "Win32" platform "${VCPKG_TARGET_ARCHITECTURE}") - vcpkg_get_windows_sdk(VCPKG_TARGET_PLATFORM_VERSION) - set(ENV{MSBFLAGS} "\ - /p:Platform=${platform} \ - /p:PlatformToolset=${VCPKG_PLATFORM_TOOLSET} \ - /p:VCPkgLocalAppDataDisabled=true \ - /p:UseIntelMKL=No \ - /p:WindowsTargetPlatformVersion=${VCPKG_TARGET_PLATFORM_VERSION} \ - /p:VcpkgConfiguration=${vcpkg_configuration} \ - ${build_in_parallel} \ - /p:ForceImportBeforeCppTargets=\"${SCRIPTS}/buildsystems/msbuild/vcpkg.targets;${build_path}/vcpkg-libs.props\" \ - /p:VcpkgTriplet=${TARGET_TRIPLET} \ - /p:VcpkgCurrentInstalledDir=\"${CURRENT_INSTALLED_DIR}\" \ - /p:ForceImportAfterCppTargets=\"${build_path}/libpq.props\" \ - ") - - message(STATUS "Building ${label}") - foreach(target IN LISTS build_targets) - string(REPLACE "client" "" target "${target}") - vcpkg_execute_required_process( - COMMAND "${PERL}" build.pl ${build_type} ${target} - WORKING_DIRECTORY "${build_path}/src/tools/msvc" - LOGNAME "build-${target}-${label}" - ) - endforeach() + # Provide paths to required tools + vcpkg_list(SET ADDITIONAL_BINARIES) + string(REPLACE [[\]] [[/]] BISON_PATH "${BISON}") + string(REPLACE [[\]] [[/]] FLEX_PATH "${FLEX}") + string(REPLACE [[\]] [[/]] PERL_PATH "${PERL}") + list(APPEND ADDITIONAL_BINARIES + "bison = ['${BISON_PATH}']" + "flex = ['${FLEX_PATH}']" + "perl = ['${PERL_PATH}']" + ) + + # Extra include/lib dirs for vcpkg dependencies (only if they exist; + # with no optional deps installed, CURRENT_INSTALLED_DIR may lack these). + # Debug and release use different lib dirs (debug libs have different + # suffixes, e.g. tcl90g.lib vs tcl90.lib). + if(EXISTS "${CURRENT_INSTALLED_DIR}/include") + list(APPEND MESON_OPTIONS "-Dextra_include_dirs=['${CURRENT_INSTALLED_DIR}/include']") + endif() + if(EXISTS "${CURRENT_INSTALLED_DIR}/lib") + list(APPEND MESON_OPTIONS_RELEASE "-Dextra_lib_dirs=['${CURRENT_INSTALLED_DIR}/lib']") + endif() + if(EXISTS "${CURRENT_INSTALLED_DIR}/debug/lib") + list(APPEND MESON_OPTIONS_DEBUG "-Dextra_lib_dirs=['${CURRENT_INSTALLED_DIR}/debug/lib']") + endif() + + vcpkg_configure_meson( + SOURCE_PATH "${source_path}" + OPTIONS + ${MESON_OPTIONS} + OPTIONS_RELEASE + ${MESON_OPTIONS_RELEASE} + OPTIONS_DEBUG + ${MESON_OPTIONS_DEBUG} + LANGUAGES C + ADDITIONAL_BINARIES + ${ADDITIONAL_BINARIES} + ) + vcpkg_install_meson() + + # Remove _shlib variants of pgcommon/pgport that consumers don't need + file(GLOB _shlib_libs + "${CURRENT_PACKAGES_DIR}/lib/*pgcommon_shlib*" + "${CURRENT_PACKAGES_DIR}/lib/*pgport_shlib*" + "${CURRENT_PACKAGES_DIR}/debug/lib/*pgcommon_shlib*" + "${CURRENT_PACKAGES_DIR}/debug/lib/*pgport_shlib*" + ) + if(_shlib_libs) + file(REMOVE ${_shlib_libs}) + endif() - message(STATUS "Installing ${label}") - vcpkg_execute_required_process( - COMMAND "${PERL}" install.pl "${packages_dir}" ${install_target} - WORKING_DIRECTORY "${build_path}/src/tools/msvc" - LOGNAME "install-${label}" + # Remove server-related installed files we don't need + file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/lib/postgresql" + "${CURRENT_PACKAGES_DIR}/debug/lib/postgresql" + "${CURRENT_PACKAGES_DIR}/share/postgresql" ) + + if(HAS_TOOLS) + set(TOOL_NAMES + clusterdb createdb createuser dropdb dropuser ecpg pgbench + pg_amcheck pg_basebackup pg_config pg_createsubscriber + pg_dump pg_dumpall pg_isready pg_receivewal pg_recvlogical + pg_restore pg_verifybackup psql reindexdb vacuumdb + ) + vcpkg_copy_tools(TOOL_NAMES ${TOOL_NAMES} AUTO_CLEAN) + else() + # Remove all executables (keep DLLs in bin/ for dynamic linkage) + file(GLOB exe_files + "${CURRENT_PACKAGES_DIR}/bin/*.exe" + "${CURRENT_PACKAGES_DIR}/debug/bin/*.exe" + ) + if(exe_files) + file(REMOVE ${exe_files}) + endif() + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/tools") + endif() + + if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin") + endif() endfunction() diff --git a/vcpkg_ports/libpq/portfile.cmake b/vcpkg_ports/libpq/portfile.cmake index 63217f607..b40d25866 100644 --- a/vcpkg_ports/libpq/portfile.cmake +++ b/vcpkg_ports/libpq/portfile.cmake @@ -2,7 +2,7 @@ vcpkg_download_distfile(ARCHIVE URLS "https://ftp.postgresql.org/pub/source/v${VERSION}/postgresql-${VERSION}.tar.bz2" "https://www.mirrorservice.org/sites/ftp.postgresql.org/source/v${VERSION}/postgresql-${VERSION}.tar.bz2" FILENAME "postgresql-${VERSION}.tar.bz2" - SHA512 23a3d983c5be49c3daabbbde35db2920bd2e2ba8d9baba805e7908da1f43153ff438c76c253ea8ee8ac6f8a9313fbf0348a1e9b45ef530c5e156fee0daceb814 + SHA512 fdbe6d726f46738cf14acab96e5c05f7d65aefe78563281b416bb14a27c7c42e4df921e26b32816a5030ddbe506b95767e2c74a35afc589916504df38d1cb11c ) vcpkg_extract_source_archive( @@ -14,13 +14,13 @@ vcpkg_extract_source_archive( unix/single-linkage.patch unix/no-server-tools.patch unix/mingw-install.patch + unix/mingw-static-importlib-fix.patch unix/python.patch windows/macro-def.patch - windows/win_bison_flex.patch - windows/msbuild.patch windows/spin_delay.patch windows/tcl-9.0-alpha.patch - android/unversioned_so.patch + windows/meson-vcpkg.patch + windows/getopt.patch ) file(GLOB _py3_include_path "${CURRENT_HOST_INSTALLED_DIR}/include/python3*") @@ -47,51 +47,39 @@ foreach(program_name IN LISTS required_programs) endforeach() if(VCPKG_DETECTED_MSVC) - if("xml" IN_LIST FEATURES) - x_vcpkg_pkgconfig_get_modules( - PREFIX PC_LIBXML2 - MODULES --msvc-syntax libxml-2.0 - LIBS - ) - separate_arguments(LIBXML2_LIBS_DEBUG NATIVE_COMMAND "${PC_LIBXML2_LIBS_DEBUG}") - separate_arguments(LIBXML2_LIBS_RELEASE NATIVE_COMMAND "${PC_LIBXML2_LIBS_RELEASE}") - endif() - if("xslt" IN_LIST FEATURES) - x_vcpkg_pkgconfig_get_modules( - PREFIX PC_LIBXSLT - MODULES --msvc-syntax libxslt - LIBS - ) - separate_arguments(LIBXSLT_LIBS_DEBUG NATIVE_COMMAND "${PC_LIBXSLT_LIBS_DEBUG}") - separate_arguments(LIBXSLT_LIBS_RELEASE NATIVE_COMMAND "${PC_LIBXSLT_LIBS_RELEASE}") - endif() - include("${CMAKE_CURRENT_LIST_DIR}/build-msvc.cmake") - if(NOT VCPKG_BUILD_TYPE) - build_msvc(DEBUG "${SOURCE_PATH}") - endif() - build_msvc(RELEASE "${SOURCE_PATH}") - - if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") - file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin") - endif() - - if(HAS_TOOLS) - vcpkg_copy_tool_dependencies("${CURRENT_PACKAGES_DIR}/tools/${PORT}") - else() - file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/tools") - endif() + build_msvc("${SOURCE_PATH}") else() file(COPY "${CMAKE_CURRENT_LIST_DIR}/Makefile" DESTINATION "${SOURCE_PATH}") vcpkg_list(SET BUILD_OPTS) - foreach(option IN ITEMS icu lz4 nls openssl readline xml xslt zlib zstd) + foreach(option IN ITEMS bonjour icu lz4 readline zlib zstd) if(option IN_LIST FEATURES) list(APPEND BUILD_OPTS --with-${option}) else() list(APPEND BUILD_OPTS --without-${option}) endif() endforeach() + if("openssl" IN_LIST FEATURES) + list(APPEND BUILD_OPTS --with-openssl) + else() + list(APPEND BUILD_OPTS --without-openssl) + endif() + if("xml" IN_LIST FEATURES) + list(APPEND BUILD_OPTS --with-libxml) + else() + list(APPEND BUILD_OPTS --without-libxml) + endif() + if("xslt" IN_LIST FEATURES) + list(APPEND BUILD_OPTS --with-libxslt) + else() + list(APPEND BUILD_OPTS --without-libxslt) + endif() + if("nls" IN_LIST FEATURES) + list(APPEND BUILD_OPTS --enable-nls) + else() + list(APPEND BUILD_OPTS --disable-nls) + endif() if("nls" IN_LIST FEATURES) set(ENV{MSGFMT} "${CURRENT_HOST_INSTALLED_DIR}/tools/gettext/bin/msgfmt${VCPKG_HOST_EXECUTABLE_SUFFIX}") endif() @@ -106,6 +94,9 @@ else() if(VCPKG_DETECTED_CMAKE_OSX_SYSROOT) list(APPEND BUILD_OPTS "PG_SYSROOT=${VCPKG_DETECTED_CMAKE_OSX_SYSROOT}") endif() + if(VCPKG_TARGET_IS_OSX) + set(ENV{LDFLAGS} "$ENV{LDFLAGS} -headerpad_max_install_names") + endif() vcpkg_configure_make( SOURCE_PATH "${SOURCE_PATH}" COPY_SOURCE diff --git a/vcpkg_ports/libpq/unix/fix-configure.patch b/vcpkg_ports/libpq/unix/fix-configure.patch index 34ceb36bc..c7cc663a2 100644 --- a/vcpkg_ports/libpq/unix/fix-configure.patch +++ b/vcpkg_ports/libpq/unix/fix-configure.patch @@ -1,79 +1,60 @@ diff --git a/configure.ac b/configure.ac -index 7f97248..48ff1a1 100644 --- a/configure.ac +++ b/configure.ac -@@ -19,7 +19,8 @@ m4_pattern_forbid(^PGAC_)dnl to catch undefined macros - - AC_INIT([PostgreSQL], [16.9], [pgsql-bugs@lists.postgresql.org], [], [https://www.postgresql.org/]) - +@@ -20,6 +20,7 @@ AC_INIT([PostgreSQL], [18.3], [pgsql-bugs@lists.postgresql.org], [], [https://ww -m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.69], [], [m4_fatal([Autoconf version 2.69 is required. +-Untested combinations of 'autoconf' and PostgreSQL versions are not +-recommended. You can remove the check from 'configure.ac' but it is then +-your responsibility whether the result works or not.])]) +cross_compiling=yes # Avoid conftest loading shared objects +m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.69], [], [m4_warn([unsupported],[Autoconf version 2.69 is required. - Untested combinations of 'autoconf' and PostgreSQL versions are not - recommended. You can remove the check from 'configure.ac' but it is then - your responsibility whether the result works or not.])]) -@@ -1311,7 +1312,8 @@ if test "$enable_thread_safety" = yes; then - fi - ++Untested combinations of 'autoconf' and PostgreSQL versions are not ++recommended. You can remove the check from 'configure.ac' but it is then ++your responsibility whether the result works or not.])]) + AC_COPYRIGHT([Copyright (c) 1996-2025, PostgreSQL Global Development Group]) + AC_CONFIG_SRCDIR([src/backend/access/common/heaptuple.c]) +@@ -1347,3 +1348,4 @@ AC_SEARCH_LIBS(pthread_barrier_wait, pthread) if test "$with_readline" = yes; then - PGAC_CHECK_READLINE + PKG_CHECK_MODULES([READLINE], [readline], [HAVE_LIBREADLINE=1], [pgac_cv_check_readline=no]) + LIBS="$READLINE_LIBS $LIBS" if test x"$pgac_cv_check_readline" = x"no"; then - AC_MSG_ERROR([readline library not found - If you have readline already installed, see config.log for details on the -@@ -1321,7 +1323,7 @@ Use --without-readline to disable readline support.]) - fi - +@@ -1357,3 +1359,3 @@ fi if test "$with_zlib" = yes; then - AC_CHECK_LIB(z, inflate, [], + PKG_CHECK_MODULES([ZLIB], [zlib], [LIBS="$ZLIB_LIBS $LIBS"], [AC_MSG_ERROR([zlib library not found - If you have zlib already installed, see config.log for details on the - failure. It is possible the compiler isn't looking in the proper directory. -@@ -1370,6 +1372,9 @@ if test "$with_ssl" = openssl ; then - # Minimum required OpenSSL version is 1.0.1 - AC_DEFINE(OPENSSL_API_COMPAT, [0x10001000L], +@@ -1394,5 +1396,9 @@ fi + AC_DEFINE(OPENSSL_API_COMPAT, [0x10101000L], [Define to the OpenSSL API version in use. This avoids deprecation warnings from newer OpenSSL versions.]) + PKG_CHECK_MODULES([CRYPTO_new_ex_data], [libcrypto], [LIBS="$CRYPTO_new_ex_data_LIBS $LIBS"], [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])]) + PKG_CHECK_MODULES([SSL_new], [libssl], [LIBS="$SSL_new_LIBS $LIBS"], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])]) + if false ; then - if test "$PORTNAME" != "win32"; then - AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])]) - AC_CHECK_LIB(ssl, SSL_new, [], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])]) -@@ -1377,6 +1382,7 @@ if test "$with_ssl" = openssl ; then - AC_SEARCH_LIBS(CRYPTO_new_ex_data, [eay32 crypto], [], [AC_MSG_ERROR([library 'eay32' or 'crypto' is required for OpenSSL])]) - AC_SEARCH_LIBS(SSL_new, [ssleay32 ssl], [], [AC_MSG_ERROR([library 'ssleay32' or 'ssl' is required for OpenSSL])]) - fi + AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])]) + AC_CHECK_LIB(ssl, SSL_new, [], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])]) + fi - # Functions introduced in OpenSSL 1.0.2. LibreSSL does not have - # SSL_CTX_set_cert_cb(). - AC_CHECK_FUNCS([X509_get_signature_nid SSL_CTX_set_cert_cb]) -@@ -1403,19 +1409,23 @@ if test "$with_pam" = yes ; then - fi - + # Functions introduced in OpenSSL 1.1.1. +@@ -1415,3 +1421,4 @@ fi if test "$with_libxml" = yes ; then - AC_CHECK_LIB(xml2, xmlSaveToBuffer, [], [AC_MSG_ERROR([library 'xml2' (version >= 2.6.23) is required for XML support])]) + PKG_CHECK_MODULES([LIBXML2], [libxml-2.0 >= 2.6.23], [AC_DEFINE(HAVE_LIBXML2,1,[Define to 1 if with xml2])], [AC_MSG_ERROR([library 'xml2' (version >= 2.6.23) is required for XML support])]) + LIBS="$LIBXML2_LIBS $LIBS" fi - +@@ -1419,3 +1426,4 @@ fi if test "$with_libxslt" = yes ; then - AC_CHECK_LIB(xslt, xsltCleanupGlobals, [], [AC_MSG_ERROR([library 'xslt' is required for XSLT support])]) + PKG_CHECK_MODULES([LIBXSLT], [libxslt], [AC_DEFINE(HAVE_LIBXSLT,1,[Define to 1 if with xslt])], [AC_MSG_ERROR([library 'xslt' is required for XSLT support])]) + LIBS="$LIBXSLT_LIBS $LIBS" fi - +@@ -1430,3 +1438,4 @@ fi if test "$with_lz4" = yes ; then - AC_CHECK_LIB(lz4, LZ4_compress_default, [], [AC_MSG_ERROR([library 'lz4' is required for LZ4 support])]) + PKG_CHECK_MODULES([LZ4], [liblz4], [AC_DEFINE(HAVE_LIBLZ4,1,[Define to 1 if with lz4])], [AC_MSG_ERROR([library 'lz4' is required for LZ4 support])]) + LIBS="$LZ4_LIBS $LIBS" fi - +@@ -1434,3 +1443,4 @@ fi if test "$with_zstd" = yes ; then - AC_CHECK_LIB(zstd, ZSTD_compress, [], [AC_MSG_ERROR([library 'zstd' is required for ZSTD support])]) + PKG_CHECK_MODULES([ZSTD], [libzstd], [AC_DEFINE(HAVE_LIBZSTD,1,[Define to 1 if with zstd])], [AC_MSG_ERROR([library 'zstd' is required for ZSTD support])]) + LIBS="$ZSTD_LIBS $LIBS" fi - - # Note: We can test for libldap_r only after we know PTHREAD_LIBS; diff --git a/vcpkg_ports/libpq/unix/installdirs.patch b/vcpkg_ports/libpq/unix/installdirs.patch index ae6653f90..bbba0fe07 100644 --- a/vcpkg_ports/libpq/unix/installdirs.patch +++ b/vcpkg_ports/libpq/unix/installdirs.patch @@ -1,10 +1,7 @@ diff --git a/src/Makefile.global.in b/src/Makefile.global.in -index 5dacc4d..a9a797e 100644 --- a/src/Makefile.global.in +++ b/src/Makefile.global.in -@@ -100,14 +100,14 @@ datarootdir := @datarootdir@ - - bindir := @bindir@ +@@ -113,42 +113,42 @@ bindir := @bindir@ -datadir := @datadir@ +datadir := @datadir@/postgresql @@ -19,7 +16,8 @@ index 5dacc4d..a9a797e 100644 ifeq "$(findstring pgsql, $(sysconfdir))" "" ifeq "$(findstring postgres, $(sysconfdir))" "" override sysconfdir := $(sysconfdir)/postgresql -@@ -116,7 +116,7 @@ endif + endif + endif libdir := @libdir@ @@ -28,7 +26,8 @@ index 5dacc4d..a9a797e 100644 ifeq "$(findstring pgsql, $(pkglibdir))" "" ifeq "$(findstring postgres, $(pkglibdir))" "" override pkglibdir := $(pkglibdir)/postgresql -@@ -125,7 +125,7 @@ endif + endif + endif includedir := @includedir@ @@ -37,7 +36,8 @@ index 5dacc4d..a9a797e 100644 ifeq "$(findstring pgsql, $(pkgincludedir))" "" ifeq "$(findstring postgres, $(pkgincludedir))" "" override pkgincludedir := $(pkgincludedir)/postgresql -@@ -134,7 +134,7 @@ endif + endif + endif mandir := @mandir@ @@ -46,3 +46,7 @@ index 5dacc4d..a9a797e 100644 ifeq "$(findstring pgsql, $(docdir))" "" ifeq "$(findstring postgres, $(docdir))" "" override docdir := $(docdir)/postgresql + endif + endif + + htmldir := @htmldir@ diff --git a/vcpkg_ports/libpq/unix/mingw-static-importlib-fix.patch b/vcpkg_ports/libpq/unix/mingw-static-importlib-fix.patch new file mode 100644 index 000000000..44d465710 --- /dev/null +++ b/vcpkg_ports/libpq/unix/mingw-static-importlib-fix.patch @@ -0,0 +1,64 @@ +diff --git a/src/Makefile.shlib b/src/Makefile.shlib +index f94d59d..77aa6bf 100644 +--- a/src/Makefile.shlib ++++ b/src/Makefile.shlib +@@ -216,8 +216,10 @@ ifeq ($(PORTNAME), win32) + ifdef SO_MAJOR_VERSION + shlib = lib$(NAME)$(DLSUFFIX) + endif ++ifneq ($(LIBPQ_LIBRARY_TYPE), static) + haslibarule = yes + endif ++endif + + + # If the shared library doesn't have an export file, mark all symbols not +@@ -323,8 +325,10 @@ else + # Win32 case + + # See notes in src/backend/parser/Makefile about the following two rules ++ifneq ($(LIBPQ_LIBRARY_TYPE), static) + $(stlib): $(shlib) + touch $@ ++endif + + # XXX A backend that loads a module linked with libgcc_s_dw2-1.dll will exit + # uncleanly, hence -static-libgcc. (Last verified with MinGW-w64 compilers + +diff --git a/src/makefiles/Makefile.win32 b/src/makefiles/Makefile.win32: +index dc1aafa..1ab97a8 100644 +--- a/src/makefiles/Makefile.win32 ++++ b/src/makefiles/Makefile.win32 +@@ -22,21 +22,32 @@ endif + endif + endif + ++ifeq (,$(filter static,$(LIBPQ_LIBRARY_TYPE))) + ifneq (,$(findstring src/common,$(subdir))) + override CPPFLAGS+= -DBUILDING_DLL + endif ++endif ++ + ++ifeq (,$(filter static,$(LIBPQ_LIBRARY_TYPE))) + ifneq (,$(findstring src/port,$(subdir))) + override CPPFLAGS+= -DBUILDING_DLL + endif ++endif ++ + ++ifeq (,$(filter static,$(LIBPQ_LIBRARY_TYPE))) + ifneq (,$(findstring timezone,$(subdir))) + override CPPFLAGS+= -DBUILDING_DLL + endif ++endif ++ + ++ifeq (,$(filter static,$(LIBPQ_LIBRARY_TYPE))) + ifneq (,$(findstring ecpg/ecpglib,$(subdir))) + override CPPFLAGS+= -DBUILDING_DLL + endif ++endif + + # required by Python headers + ifneq (,$(findstring src/pl/plpython,$(subdir))) diff --git a/vcpkg_ports/libpq/unix/no-server-tools.patch b/vcpkg_ports/libpq/unix/no-server-tools.patch index f83682afb..1677edb75 100644 --- a/vcpkg_ports/libpq/unix/no-server-tools.patch +++ b/vcpkg_ports/libpq/unix/no-server-tools.patch @@ -2,7 +2,7 @@ diff --git a/src/bin/Makefile b/src/bin/Makefile index 7f9dde9..bc6d835 100644 --- a/src/bin/Makefile +++ b/src/bin/Makefile -@@ -13,29 +13,20 @@ subdir = src/bin +@@ -13,31 +13,20 @@ subdir = src/bin top_builddir = ../.. include $(top_builddir)/src/Makefile.global @@ -15,6 +15,7 @@ index 7f9dde9..bc6d835 100644 - pg_archivecleanup \ pg_basebackup \ - pg_checksums \ +- pg_combinebackup \ pg_config \ - pg_controldata \ - pg_ctl \ @@ -26,6 +27,7 @@ index 7f9dde9..bc6d835 100644 - pg_upgrade \ pg_verifybackup \ - pg_waldump \ +- pg_walsummary \ pgbench \ psql \ scripts diff --git a/vcpkg_ports/libpq/unix/single-linkage.patch b/vcpkg_ports/libpq/unix/single-linkage.patch index dd149c7d3..1c334a58a 100644 --- a/vcpkg_ports/libpq/unix/single-linkage.patch +++ b/vcpkg_ports/libpq/unix/single-linkage.patch @@ -42,8 +42,8 @@ index 8abdb09..185461e 100644 +ifeq ($(LIBPQ_LIBRARY_TYPE), shared) libpq-refs-stamp: $(shlib) ifneq ($(enable_coverage), yes) - ifeq (,$(filter aix solaris,$(PORTNAME))) -@@ -124,6 +125,10 @@ ifeq (,$(filter aix solaris,$(PORTNAME))) + ifeq (,$(filter solaris,$(PORTNAME))) +@@ -124,6 +125,10 @@ ifeq (,$(filter solaris,$(PORTNAME))) endif endif touch $@ diff --git a/vcpkg_ports/libpq/vcpkg.json b/vcpkg_ports/libpq/vcpkg.json index 2ab73a53e..782747bda 100644 --- a/vcpkg_ports/libpq/vcpkg.json +++ b/vcpkg_ports/libpq/vcpkg.json @@ -1,7 +1,6 @@ { "name": "libpq", - "version": "16.9", - "port-version": 2, + "version": "18.3", "description": "The official database access API of postgresql", "homepage": "https://www.postgresql.org/", "license": "PostgreSQL", @@ -20,7 +19,7 @@ "host": true }, { - "name": "vcpkg-pkgconfig-get-modules", + "name": "vcpkg-tool-meson", "host": true, "platform": "windows & !mingw" } diff --git a/vcpkg_ports/libpq/windows/getopt.patch b/vcpkg_ports/libpq/windows/getopt.patch new file mode 100644 index 000000000..073b32adb --- /dev/null +++ b/vcpkg_ports/libpq/windows/getopt.patch @@ -0,0 +1,21 @@ +diff --git a/meson.build b/meson.build +--- a/meson.build ++++ b/meson.build +@@ -2624,7 +2624,7 @@ header_checks = [ + 'copyfile.h', + 'crtdefs.h', + 'execinfo.h', +- 'getopt.h', ++ # 'getopt.h', # vcpkg: skip to avoid getopt-win32 header pollution + 'ifaddrs.h', + 'mbarrier.h', + 'strings.h', +@@ -2714,7 +2714,7 @@ endforeach + + if cc.has_type('struct option', + args: test_c_args, include_directories: postgres_inc, +- prefix: '@0@'.format(cdata.get('HAVE_GETOPT_H')) == '1' ? '#include ' : '') ++ prefix: '@0@'.format(cdata.get('HAVE_GETOPT_H', 0)) == '1' ? '#include ' : '') + cdata.set('HAVE_STRUCT_OPTION', 1) + endif + diff --git a/vcpkg_ports/libpq/windows/macro-def.patch b/vcpkg_ports/libpq/windows/macro-def.patch index 1d16c1270..7eb508d88 100644 --- a/vcpkg_ports/libpq/windows/macro-def.patch +++ b/vcpkg_ports/libpq/windows/macro-def.patch @@ -2,7 +2,7 @@ diff --git a/src/include/common/checksum_helper.h b/src/include/common/checksum_ index cac7570ea..d0ca1243c 100644 --- a/src/include/common/checksum_helper.h +++ b/src/include/common/checksum_helper.h -@@ -33,7 +28,13 @@ +@@ -28,7 +28,13 @@ */ typedef enum pg_checksum_type { diff --git a/vcpkg_ports/libpq/windows/meson-vcpkg.patch b/vcpkg_ports/libpq/windows/meson-vcpkg.patch new file mode 100644 index 000000000..84543bcd0 --- /dev/null +++ b/vcpkg_ports/libpq/windows/meson-vcpkg.patch @@ -0,0 +1,45 @@ +diff --git a/meson.build b/meson.build +--- a/meson.build ++++ b/meson.build +@@ -83,7 +83,7 @@ endif + ############################################################### + + postgres_inc_d = ['src/include'] +-postgres_inc_d += get_option('extra_include_dirs') ++# postgres_inc_d += get_option('extra_include_dirs') # vcpkg: moved below + + postgres_lib_d = get_option('extra_lib_dirs') + +@@ -316,6 +316,7 @@ elif host_system == 'windows' + postgres_inc_d += 'src/include/port/win32' + if cc.get_id() == 'msvc' + postgres_inc_d += 'src/include/port/win32_msvc' ++ postgres_inc_d += get_option('extra_include_dirs') # vcpkg: moved here for correct priority + endif + + windows = import('windows') +@@ -3218,6 +3219,7 @@ endif + generated_headers = [] + # headers that the backend build depends on + generated_backend_headers = [] ++generated_backend_sources = [] + # configure_files() output, needs a way of converting to file names + configure_files = [] + +@@ -3372,12 +3374,12 @@ test_install_libs = [] + + subdir('src') + +-subdir('contrib') ++# subdir('contrib') # vcpkg: skip + +-subdir('src/test') +-subdir('src/interfaces/ecpg/test') ++# subdir('src/test') # vcpkg: skip ++# subdir('src/interfaces/ecpg/test') # vcpkg: skip + +-subdir('doc/src/sgml') ++# subdir('doc/src/sgml') # vcpkg: skip + + generated_sources_ac += {'': ['GNUmakefile']} + diff --git a/vcpkg_ports/libpq/windows/msbuild.patch b/vcpkg_ports/libpq/windows/msbuild.patch deleted file mode 100644 index e6c70ad09..000000000 --- a/vcpkg_ports/libpq/windows/msbuild.patch +++ /dev/null @@ -1,398 +0,0 @@ -diff --git a/src/tools/msvc/Install.pm b/src/tools/msvc/Install.pm -index 05548d7..097db91 100644 ---- a/src/tools/msvc/Install.pm -+++ b/src/tools/msvc/Install.pm -@@ -53,6 +53,11 @@ sub Install - my $target = shift; - $insttype = shift; - $insttype = "all" unless ($insttype); -+ if ($insttype eq 'core') -+ { -+ $insttype = 'client'; -+ @client_program_files = ( 'libecpg','libecpg_compat', 'libpgtypes', 'libpq' ); -+ } - - # if called from vcregress, the config will be passed to us - # so no need to re-include these -@@ -89,7 +94,7 @@ sub Install - my $majorver = DetermineMajorVersion(); - print "Installing version $majorver for $conf in $target\n"; - -- my @client_dirs = ('bin', 'lib', 'share', 'symbols'); -+ my @client_dirs = ('bin', 'lib', 'share', 'tools', 'share/libpq', 'tools/libpq'); - my @all_dirs = ( - @client_dirs, 'doc', 'doc/contrib', 'doc/extension', 'share/contrib', - 'share/extension', 'share/timezonesets', 'share/tsearch_data'); -@@ -117,11 +122,11 @@ sub Install - } - }, - @top_dir); -- CopySetOfFiles('config files', $sample_files, $target . '/share/'); -+ CopySetOfFiles('config files', $sample_files, $target . '/share/libpq/'); - CopyFiles( - 'Import libraries', - $target . '/lib/', -- "$conf\\", "postgres\\postgres.lib", "libpgcommon\\libpgcommon.lib", -+ "$conf\\", "libpgcommon\\libpgcommon.lib", - "libpgport\\libpgport.lib"); - CopyContribFiles($config, $target); - CopyIncludeFiles($target); -@@ -293,7 +298,16 @@ sub CopySolutionOutput - { - if ($1 == 1) - { -- push(@{ $install_list{'bin'} }, "exe"); -+ push(@{ $install_list{'tools\\libpq'} }, "exe"); -+ } -+ elsif ($1 == 2) -+ { -+ push(@{ $install_list{'bin'} }, "dll"); -+ push(@{ $install_list{'lib'} }, "lib") if $is_sharedlib; # not for plugins -+ } -+ elsif ($is_sharedlib) # forced to static lib by vcpkg triplet -+ { -+ push(@{ $install_list{'lib'} }, "lib"); - } - elsif ($1 == 2) - { -@@ -317,7 +331,16 @@ sub CopySolutionOutput - { - if ($1 eq 'Application') - { -- push(@{ $install_list{'bin'} }, "exe"); -+ push(@{ $install_list{'tools\\libpq'} }, "exe"); -+ } -+ elsif ($1 eq 'DynamicLibrary') -+ { -+ push(@{ $install_list{'bin'} }, "dll"); -+ push(@{ $install_list{'lib'} }, "lib") if $is_sharedlib; # not for plugins -+ } -+ elsif ($is_sharedlib) # forced to static lib by vcpkg triplet -+ { -+ push(@{ $install_list{'lib'} }, "lib"); - } - elsif ($1 eq 'DynamicLibrary') - { -@@ -350,7 +373,8 @@ sub CopySolutionOutput - || croak "Could not copy $pf.$ext\n"; - } - } -- lcopy("$conf\\$pf\\$pf.pdb", "$target\\symbols\\$pf.pdb") -+ $1 ne 'DynamicLibrary' || -+ lcopy("$conf\\$pf\\$pf.pdb", "$target\\bin\\$pf.pdb") - || croak "Could not copy $pf.pdb\n"; - print "."; - } -@@ -453,7 +477,7 @@ sub CopySubdirFiles - foreach my $f (split /\s+/, $flist) - { - lcopy("$subdir/$module/$f.control", -- "$target/share/extension/$f.control") -+ "$target/share/libpq/extension/$f.control") - || croak("Could not copy file $f.control in contrib $module"); - print '.'; - } -@@ -471,7 +495,7 @@ sub CopySubdirFiles - foreach my $f (split /\s+/, $flist) - { - lcopy("$subdir/$module/$f", -- "$target/share/$moduledir/" . basename($f)) -+ "$target/share/libpq/$moduledir/" . basename($f)) - || croak("Could not copy file $f in contrib $module"); - print '.'; - } -@@ -486,7 +510,7 @@ sub CopySubdirFiles - foreach my $f (split /\s+/, $flist) - { - lcopy("$subdir/$module/$f", -- "$target/share/tsearch_data/" . basename($f)) -+ "$target/share/libpq/tsearch_data/" . basename($f)) - || croak("Could not copy file $f in $subdir $module"); - print '.'; - } -@@ -549,7 +573,7 @@ sub CopySubdirFiles - if ($module eq 'spi'); - foreach my $f (split /\s+/, $flist) - { -- lcopy("$subdir/$module/$f", "$target/doc/$moduledir/$f") -+ lcopy("$subdir/$module/$f", "$target/share/libpq/doc/$moduledir/$f") - || croak("Could not copy file $f in contrib $module"); - print '.'; - } -@@ -675,7 +699,7 @@ sub GenerateNLSFiles - my $majorver = shift; - - print "Installing NLS files..."; -- EnsureDirectories($target, "share/locale"); -+ EnsureDirectories($target, "share/libpq/locale"); - my @flist; - File::Find::find( - { -@@ -697,12 +721,12 @@ sub GenerateNLSFiles - next unless /([^\/]+)\.po/; - $lang = $1; - -- EnsureDirectories($target, "share/locale/$lang", -- "share/locale/$lang/LC_MESSAGES"); -+ EnsureDirectories($target, "share/libpq/locale/$lang", -+ "share/libpq/locale/$lang/LC_MESSAGES"); - my @args = ( -- "$nlspath\\bin\\msgfmt", -+ "msgfmt", - '-o', -- "$target\\share\\locale\\$lang\\LC_MESSAGES\\$prgm-$majorver.mo", -+ "$target\\share\\libpq\\locale\\$lang\\LC_MESSAGES\\$prgm-$majorver.mo", - $_); - system(@args) && croak("Could not run msgfmt on $dir\\$_"); - print "."; -diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm -index 62fec1f..ecb1b86 100644 ---- a/src/tools/msvc/MSBuildProject.pm -+++ b/src/tools/msvc/MSBuildProject.pm -@@ -80,14 +80,14 @@ EOF - print $f < - EOF -- -+ my $maybe_dll = $self->{solution}->{options}->{VCPKG_CRT_LINKAGE} eq 'dynamic' ? "DLL" : ''; - $self->WriteItemDefinitionGroup( - $f, 'Debug', - { - defs => "_DEBUG;DEBUG=1", - opt => 'Disabled', - strpool => 'false', -- runtime => 'MultiThreadedDebugDLL' -+ runtime => 'MultiThreadedDebug' . $maybe_dll - }); - $self->WriteItemDefinitionGroup( - $f, -@@ -96,7 +96,7 @@ EOF - defs => "", - opt => 'Full', - strpool => 'true', -- runtime => 'MultiThreadedDLL' -+ runtime => 'MultiThreaded' . $maybe_dll - }); - return; - } -@@ -266,6 +266,8 @@ sub WriteConfigurationPropertyGroup - ($self->{type} eq "exe") - ? 'Application' - : ($self->{type} eq "dll" ? 'DynamicLibrary' : 'StaticLibrary'); -+ if ($self->{solution}->{options}->{VCPKG_LIBRARY_LINKAGE} eq 'static') -+ { $cfgtype =~ s/DynamicLibrary/StaticLibrary/; } - - print $f < -@@ -311,7 +313,9 @@ sub WriteItemDefinitionGroup - my $libs = $self->GetAdditionalLinkerDependencies($cfgname, ';'); - - my $targetmachine = -- $self->{platform} eq 'Win32' ? 'MachineX86' : 'MachineX64'; -+ 'Machine' . uc($self->{platform}); -+ $targetmachine =~ s/WIN32/X86/; -+ my $randomizebase = ($self->{platform} =~ /^ARM/) ? 'true' : 'false'; - my $arch = $self->{platform} eq 'Win32' ? 'x86' : 'x86_64'; - - my $includes = join ';', @{ $self->{includes} }, ""; -diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm -index 9e05eb9..8ac0a5d 100644 ---- a/src/tools/msvc/Mkvcbuild.pm -+++ b/src/tools/msvc/Mkvcbuild.pm -@@ -125,8 +125,10 @@ sub mkvcbuild - - if ($vsVersion >= '9.00') - { -+ if ($solution->{platform} !~ /^ARM/) { - push(@pgportfiles, 'pg_crc32c_sse42_choose.c'); - push(@pgportfiles, 'pg_crc32c_sse42.c'); -+ } - push(@pgportfiles, 'pg_crc32c_sb8.c'); - } - else -@@ -208,6 +210,7 @@ sub mkvcbuild - 'syncrep_gram.y'); - $postgres->AddFiles('src/backend/utils/adt', 'jsonpath_scan.l', - 'jsonpath_gram.y'); -+ ($config->{VCPKG_LIBRARY_LINKAGE} eq 'dynamic') && - $postgres->AddDefine('BUILDING_DLL'); - $postgres->AddLibrary('secur32.lib'); - $postgres->AddLibrary('ws2_32.lib'); -@@ -252,12 +255,13 @@ sub mkvcbuild - $pltcl->AddIncludeDir($solution->{options}->{tcl} . '/include'); - $pltcl->AddReference($postgres); - -- for my $tclver (qw(86t 86 85 84)) -+ my $v = $solution->{options}->{tcl_version}; -+ for my $tclver ( ("${v}","${v}s","${v}sx") ) - { - my $tcllib = $solution->{options}->{tcl} . "/lib/tcl$tclver.lib"; - if (-e $tcllib) - { -- $pltcl->AddLibrary($tcllib); -+ $pltcl->AddLibrary("\$(VcpkgTcl${tclver}Libs)"); - $found = 1; - last; - } -@@ -512,8 +516,7 @@ sub mkvcbuild - . "print(str(sys.version_info[0])+str(sys.version_info[1]))"; - my $prefixcmd = - qq("$solution->{options}->{python}\\python" -c "$pythonprog"); -- my $pyout = `$prefixcmd`; -- die "Could not query for python version!\n" if $?; -+ my $pyout = "$solution->{options}->{python}\n$solution->{options}->{python_version}"; - my ($pyprefix, $pyver) = split(/\r?\n/, $pyout); - - # Sometimes (always?) if python is not present, the execution -@@ -529,8 +532,8 @@ sub mkvcbuild - - my $plpython = $solution->AddProject('plpython' . $pymajorver, - 'dll', 'PLs', 'src/pl/plpython'); -- $plpython->AddIncludeDir($pyprefix . '/include'); -- $plpython->AddLibrary($pyprefix . "/Libs/python$pyver.lib"); -+ $plpython->AddIncludeDir($pyprefix . "/include/python$pyver"); -+ $plpython->AddLibrary('$(VcpkgPythonLibs)'); - $plpython->AddReference($postgres); - - # Add transform modules dependent on plpython -diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm -index 0507ad0..48caab9 100644 ---- a/src/tools/msvc/Project.pm -+++ b/src/tools/msvc/Project.pm -@@ -167,6 +167,11 @@ sub AddReference - } - $self->AddLibrary( - "__CFGNAME__/" . $ref->{name} . "/" . $ref->{name} . ".lib"); -+ -+ if ($self->{solution}->{options}->{VCPKG_LIBRARY_LINKAGE} eq 'static') -+ { -+ map { $self->AddLibrary($_) } @{ $ref->{libraries} }; -+ } - } - return; - } -diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm -index b6d31c3..27d89fc 100644 ---- a/src/tools/msvc/Solution.pm -+++ b/src/tools/msvc/Solution.pm -@@ -63,6 +63,11 @@ sub DeterminePlatform - my $self = shift; - - if ($^O eq "MSWin32") -+ { -+ $self->{platform} = uc($self->{options}->{VCPKG_TARGET_ARCHITECTURE}); -+ $self->{platform} =~ s/^X86$/Win32/; -+ } -+ elsif (0) - { - # Examine CL help output to determine if we are in 32 or 64-bit mode. - my $output = `cl /help 2>&1`; -@@ -124,6 +129,9 @@ sub copyFile - sub GetOpenSSLVersion - { - my $self = shift; -+ if ($self->{options}->{openssl_version} =~ /(\d+)\.(\d+)\.(\d+)/m) { -+ return ($1, $2, $3); -+ } - - # Attempt to get OpenSSL version and location. This assumes that - # openssl.exe is in the specified directory. -@@ -148,7 +156,7 @@ sub GetOpenSSLVersion - sub GenerateFiles - { - my $self = shift; -- my $bits = $self->{platform} eq 'Win32' ? 32 : 64; -+ my $bits = $self->{platform} =~ /64/ ? 64 : 32; - my $ac_init_found = 0; - my $package_name; - my $package_version; -@@ -440,7 +448,7 @@ sub GenerateFiles - USE_PAM => undef, - USE_SLICING_BY_8_CRC32C => undef, - USE_SSE42_CRC32C => undef, -- USE_SSE42_CRC32C_WITH_RUNTIME_CHECK => 1, -+ USE_SSE42_CRC32C_WITH_RUNTIME_CHECK => $self->{platform} =~ /^ARM/ ? undef : 1, - USE_SYSTEMD => undef, - USE_SYSV_SEMAPHORES => undef, - USE_SYSV_SHARED_MEMORY => undef, -@@ -725,14 +733,14 @@ sub GenerateFiles - || confess "Could not open pg_config_paths.h"; - print $o <{options}->{zlib}) - { - $proj->AddIncludeDir($self->{options}->{zlib} . '\include'); -- $proj->AddLibrary($self->{options}->{zlib} . '\lib\zdll.lib'); -+ $proj->AddLibrary('$(VcpkgZlibLibs)'); - } - if ($self->{options}->{openssl}) - { - $proj->AddIncludeDir($self->{options}->{openssl} . '\include'); -+ $proj->AddLibrary('$(VcpkgOpensslLibs)'); -+ } -+ elsif (0) -+ { - my ($digit1, $digit2, $digit3) = $self->GetOpenSSLVersion(); - - # Starting at version 1.1.0 the OpenSSL installers have -@@ -1032,7 +1044,7 @@ sub AddProject - if ($self->{options}->{nls}) - { - $proj->AddIncludeDir($self->{options}->{nls} . '\include'); -- $proj->AddLibrary($self->{options}->{nls} . '\lib\libintl.lib'); -+ $proj->AddLibrary('$(VcpkgNlsLibs)'); - } - if ($self->{options}->{gss}) - { -@@ -1065,6 +1077,10 @@ sub AddProject - if ($self->{options}->{icu}) - { - $proj->AddIncludeDir($self->{options}->{icu} . '\include'); -+ $proj->AddLibrary('$(VcpkgIcuLibs)'); -+ } -+ elsif (0) -+ { - if ($self->{platform} eq 'Win32') - { - $proj->AddLibrary($self->{options}->{icu} . '\lib\icuin.lib'); -@@ -1082,22 +1098,22 @@ sub AddProject - { - $proj->AddIncludeDir($self->{options}->{xml} . '\include'); - $proj->AddIncludeDir($self->{options}->{xml} . '\include\libxml2'); -- $proj->AddLibrary($self->{options}->{xml} . '\lib\libxml2.lib'); -+ $proj->AddLibrary('$(VcpkgXmlLibs)'); - } - if ($self->{options}->{xslt}) - { - $proj->AddIncludeDir($self->{options}->{xslt} . '\include'); -- $proj->AddLibrary($self->{options}->{xslt} . '\lib\libxslt.lib'); -+ $proj->AddLibrary('$(VcpkgXsltLibs)'); - } - if ($self->{options}->{lz4}) - { - $proj->AddIncludeDir($self->{options}->{lz4} . '\include'); -- $proj->AddLibrary($self->{options}->{lz4} . '\lib\liblz4.lib'); -+ $proj->AddLibrary('$(VcpkgLz4Libs)'); - } - if ($self->{options}->{zstd}) - { - $proj->AddIncludeDir($self->{options}->{zstd} . '\include'); -- $proj->AddLibrary($self->{options}->{zstd} . '\lib\libzstd.lib'); -+ $proj->AddLibrary('$(VcpkgZstdLibs)'); - } - if ($self->{options}->{uuid}) - { diff --git a/vcpkg_ports/libpq/windows/win_bison_flex.patch b/vcpkg_ports/libpq/windows/win_bison_flex.patch deleted file mode 100644 index fc8230193..000000000 --- a/vcpkg_ports/libpq/windows/win_bison_flex.patch +++ /dev/null @@ -1,42 +0,0 @@ -diff --git a/src/tools/msvc/pgbison.pl b/src/tools/msvc/pgbison.pl -index 25df669..373bedd 100644 ---- a/src/tools/msvc/pgbison.pl -+++ b/src/tools/msvc/pgbison.pl -@@ -13,7 +13,7 @@ use File::Basename; - - do './src/tools/msvc/buildenv.pl' if -e 'src/tools/msvc/buildenv.pl'; - --my ($bisonver) = `bison -V`; # grab first line -+my ($bisonver) = `win_bison -V`; # grab first line - $bisonver = (split(/\s+/, $bisonver))[3]; # grab version number - - unless ($bisonver ge '2.3') -@@ -51,5 +51,5 @@ my $headerflag = ($make =~ /^$basetarg:\s+BISONFLAGS\b.*-d/m ? '-d' : ''); - - my $nodep = $bisonver ge '3.0' ? "-Wno-deprecated" : ""; - --system("bison $nodep $headerflag $input -o $output"); -+system("win_bison $nodep $headerflag $input -o $output"); - exit $? >> 8; -diff --git a/src/tools/msvc/pgflex.pl b/src/tools/msvc/pgflex.pl -index c308a08..0807ce7 100644 ---- a/src/tools/msvc/pgflex.pl -+++ b/src/tools/msvc/pgflex.pl -@@ -16,7 +16,7 @@ $ENV{CYGWIN} = 'nodosfilewarning'; - - do './src/tools/msvc/buildenv.pl' if -e 'src/tools/msvc/buildenv.pl'; - --my ($flexver) = `flex -V`; # grab first line -+my ($flexver) = `win_flex -V`; # grab first line - $flexver = (split(/\s+/, $flexver))[1]; - $flexver =~ s/[^0-9.]//g; - my @verparts = split(/\./, $flexver); -@@ -52,7 +52,7 @@ close($mf); - my $basetarg = basename($output); - my $flexflags = ($make =~ /^$basetarg:\s*FLEXFLAGS\s*=\s*(\S.*)/m ? $1 : ''); - --system("flex $flexflags -o$output $input"); -+system("win_flex $flexflags -o$output $input"); - if ($? == 0) - { -