Message-ID: From: "kenjiuno (@kenjiuno)" To: "postgresql-interfaces/psqlodbc" Date: Tue, 06 May 2025 03:00:12 +0000 Subject: Re: [postgresql-interfaces/psqlodbc] issue #36: Request: Add Windows for ARM support In-Reply-To: References: List-Id: X-GitHub-Author-Login: kenjiuno X-GitHub-Comment-Id: 2853139223 X-GitHub-Comment-Type: issue_comment X-GitHub-Issue: 36 X-GitHub-Repo: postgresql-interfaces/psqlodbc X-GitHub-Type: comment X-GitHub-Url: https://github.com/postgresql-interfaces/psqlodbc/issues/36#issuecomment-2853139223 Content-Type: text/plain; charset=utf-8 Hi. Although I'm unsure I can help you, I'll share notes from my memo. --- I needed to use `meson + ninja` for cross compilation. My PC is `x64`, and the target is `Arm64` (Arm64X). `meson + msbuild` seems to have a problem: meson system sometimes launches a child msbuild, but important properties like `/p:Configuration=...` are not propagated. [custom_target() and run_target() fail to execute with VS backend when buildtype is set to release · Issue #8237 · mesonbuild/meson](https://github.com/mesonbuild/meson/issues/8237) There is a workaround using an environment variable. ```bat SET CONFIGURATION=Release ``` --- Are you going to link OpenSSL (`Arm64`) into PostgreSQL (`arm64ec`)? > "C:\repos\postgresql-17.0\build-last-try-4\postgresql.sln" (default target) (1) -> > "C:\repos\postgresql-17.0\build-last-try-4\src\interfaces\libpq\886b0b2@@libpq@sha.vcxproj" (default target) (25) -> > (Link target) -> > fe-secure-openssl.c.obj : error LNK2001: unresolved external symbol #GENERAL_NAME_free (EC Symbol) [C:\repos\postgresql-17.0\build-last-try-4\src\interfaces\libpq\886b0b2@@libpq@sha.vcxproj] > fe-secure-openssl.c.obj : error LNK2019: unresolved external symbol GENERAL_NAME_free referenced in function #pgtls_verify_peer_name_matches_certificate_guts (EC Symbol) [C:\repos\postgresql-17.0\build-last-try-4\src\interfaces\libpq\886b0b2@@libpq@sha.vcxproj] > fe-secure-openssl.c.obj : error LNK2019: unresolved external symbol ENGINE_by_id referenced in function #ENGINE_by_id$exit_thunk (EC Symbol) [C:\repos\postgresql-17.0\build-last-try-4\src\interfaces\libpq\886b0b2@@libpq@sha.vcxproj] If you are going to build PostgreSQL (`arm64ec`), you need to prepare OpenSSL (`arm64ec`). As far as I know, there is no official OpenSSL `arm64ec` binary yet. (It may need to be compiled by self) --- This `postgres.def` is generated by a wrong `src/tools/msvc_gendef.pl`, where it doesn't recognize `aarch64` yet. > postgres.def : error LNK2001: unresolved external symbol brin_parallel_build_main [C:\repos\postgresql-17.0\build-last-try-3\src\backend\22e3565@@postgres@exe.vcxproj] Check https://github.com/postgres/postgres/blob/5e2f3df49d4298c6097789364a5a53be172f6e85/src/backend/access/brin/brin.c#L2853 This symbol should prefix `_` symbol natively. ```c /* * Perform work within a launched parallel process. */ void _brin_parallel_build_main(dsm_segment *seg, shm_toc *toc) { // ... } ``` Fix `src\tools\msvc_gendef.pl` ```patch src/tools/msvc_gendef.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tools/msvc_gendef.pl b/src/tools/msvc_gendef.pl index 404076dbbc..c23320b1d2 100644 --- a/src/tools/msvc_gendef.pl +++ b/src/tools/msvc_gendef.pl @@ -122,7 +122,7 @@ sub writedef # Strip the leading underscore for win32, but not x64 $f =~ s/^_// - unless ($arch eq "x86_64"); + unless ($arch eq 'x86_64' || $arch eq 'aarch64'); # Emit just the name if it's a function symbol, or emit the name # decorated with the DATA option for variables. @@ -143,7 +143,7 @@ sub writedef sub usage { die("Usage: msvc_gendef.pl --arch --deffile --tempdir files-or-directories\n" - . " arch: x86 | x86_64\n" + . " arch: x86 | x86_64 | aarch64\n" . " deffile: path of the generated file\n" . " tempdir: directory for temporary files\n" . " files or directories: object files or directory containing object files\n" @@ -160,7 +160,7 @@ GetOptions( 'tempdir:s' => \$tempdir,) or usage(); usage("arch: $arch") - unless ($arch eq 'x86' || $arch eq 'x86_64'); + unless ($arch eq 'x86' || $arch eq 'x86_64' || $arch eq 'aarch64'); my @files; ``` Delete generated `BUILDROOT\src\backend\postgres.def` and also build again. Check `BUILDROOT\src\backend\postgres.def` Ensure that `_brin_parallel_build_main` exists. ![Image](https://github.com/user-attachments/assets/8ce2a794-f206-4a59-b178-33456cc400db) --- > "C:\repos\psqlodbc\winbuild\platformbuild.vcxproj" (Build target) (1) -> > "C:\repos\psqlodbc\winbuild\psqlodbc.vcxproj" (Build target) (2) -> > (Link target) -> > columninfo.obj : error LNK2001: unresolved external symbol PQfmod (EC Symbol) [C:\repos\psqlodbc\winbuild\psqlodbc.vcxproj] > columninfo.obj : error LNK2001: unresolved external symbol #PQfmod (EC Symbol) [C:\repos\psqlodbc\winbuild\psqlodbc.vcxproj] This link target is `Arm64X`?