Обсуждение: Trying to build x86 version on windows using meson
Greetings,
I am getting the following error
meson.build:1479:17: ERROR: Can not run test applications in this cross environment.
Have configured for amd64_x86
Running `meson setup --wipe build --prefix=c:\postgres86`
The docs say it is possible to build postgres for x86. Are there specific instructions ?
Dave Cramer
Hi, On 2024-03-20 16:14:23 -0400, Dave Cramer wrote: > I am getting the following error > > meson.build:1479:17: ERROR: Can not run test applications in this cross > environment. > > Have configured for amd64_x86 > > Running `meson setup --wipe build --prefix=c:\postgres86` This is not enough information to debug anything. At the very least we need the exact steps performed to set up the build and meson-logs/meson-log.txt > The docs say it is possible to build postgres for x86. Are there specific > instructions ? It should work. Greetings, Andres Freund
On Wed, 20 Mar 2024 at 17:11, Andres Freund <andres@anarazel.de> wrote:
Hi,
On 2024-03-20 16:14:23 -0400, Dave Cramer wrote:
> I am getting the following error
>
> meson.build:1479:17: ERROR: Can not run test applications in this cross
> environment.
>
> Have configured for amd64_x86
>
> Running `meson setup --wipe build --prefix=c:\postgres86`
This is not enough information to debug anything. At the very least we need
the exact steps performed to set up the build and meson-logs/meson-log.txt
First off this is on an ARM64 machine
The last error from meson-log.txt is
...
Checking if "c99" compiles: YES
meson.build:1479:17: ERROR: Can not run test applications in this cross environment.
...
> The docs say it is possible to build postgres for x86. Are there specific
> instructions ?
It should work.
Greetings,
Andres Freund
Вложения
Hi, On 2024-03-20 17:49:14 -0400, Dave Cramer wrote: > On Wed, 20 Mar 2024 at 17:11, Andres Freund <andres@anarazel.de> wrote: > > On 2024-03-20 16:14:23 -0400, Dave Cramer wrote: > > > I am getting the following error > > > > > > meson.build:1479:17: ERROR: Can not run test applications in this cross > > > environment. > > > > > > Have configured for amd64_x86 > > > > > > Running `meson setup --wipe build --prefix=c:\postgres86` > > > > This is not enough information to debug anything. At the very least we need > > the exact steps performed to set up the build and meson-logs/meson-log.txt > > > First off this is on an ARM64 machine Uh, that's a fairly crucial bit - you're actually trying to cross compile then. I don't know much about cross compiling on windows, so it's certainly possible there's still some gaps there. > > The last error from meson-log.txt is > > ... > Checking if "c99" compiles: YES > > meson.build:1479:17: ERROR: Can not run test applications in this cross > environment. > ... That's not the meson-log.txt that you attached though? Greetings, Andres Freund
On Thu, 21 Mar 2024 at 11:00, Andres Freund <andres@anarazel.de> wrote: > > On 2024-03-20 17:49:14 -0400, Dave Cramer wrote: > > First off this is on an ARM64 machine > > Uh, that's a fairly crucial bit - you're actually trying to cross compile > then. I don't know much about cross compiling on windows, so it's certainly > possible there's still some gaps there. How would initdb.exe / pg_regress.exe even run on the x86 build machine if it's compiled for ARM? David
Hi, On 2024-03-21 11:02:27 +1300, David Rowley wrote: > On Thu, 21 Mar 2024 at 11:00, Andres Freund <andres@anarazel.de> wrote: > > > > On 2024-03-20 17:49:14 -0400, Dave Cramer wrote: > > > First off this is on an ARM64 machine > > > > Uh, that's a fairly crucial bit - you're actually trying to cross compile > > then. I don't know much about cross compiling on windows, so it's certainly > > possible there's still some gaps there. > > How would initdb.exe / pg_regress.exe even run on the x86 build > machine if it's compiled for ARM? I think this is building on an ARM64 host, targeting 32bit x86. Obviously tests can't run in that environment, but building should be possible. I can e.g. build postgres for x86-64 windows on my linux machine, but can't run the tests (in theory they could be run with wine, but wine isn't complete enough to run postgres). Greetings, Andres Freund
On Wed, Mar 20, 2024 at 6:21 PM Andres Freund <andres@anarazel.de> wrote:
Hi,
On 2024-03-21 11:02:27 +1300, David Rowley wrote:
> On Thu, 21 Mar 2024 at 11:00, Andres Freund <andres@anarazel.de> wrote:
> >
> > On 2024-03-20 17:49:14 -0400, Dave Cramer wrote:
> > > First off this is on an ARM64 machine
> >
> > Uh, that's a fairly crucial bit - you're actually trying to cross compile
> > then. I don't know much about cross compiling on windows, so it's certainly
> > possible there's still some gaps there.
>
> How would initdb.exe / pg_regress.exe even run on the x86 build
> machine if it's compiled for ARM?
I think this is building on an ARM64 host, targeting 32bit x86.
Obviously tests can't run in that environment, but building should be
possible. I can e.g. build postgres for x86-64 windows on my linux machine,
but can't run the tests (in theory they could be run with wine, but wine isn't
complete enough to run postgres).
Windows apparently has some magic built in for this:
cheers
andrew
On 20.03.24 22:49, Dave Cramer wrote: > > > > On Wed, 20 Mar 2024 at 17:11, Andres Freund <andres@anarazel.de > <mailto:andres@anarazel.de>> wrote: > > Hi, > > On 2024-03-20 16:14:23 -0400, Dave Cramer wrote: > > I am getting the following error > > > > meson.build:1479:17: ERROR: Can not run test applications in this > cross > > environment. > > > > Have configured for amd64_x86 > > > > Running `meson setup --wipe build --prefix=c:\postgres86` > > This is not enough information to debug anything. At the very least > we need > the exact steps performed to set up the build and > meson-logs/meson-log.txt > > First off this is on an ARM64 machine > > The last error from meson-log.txt is > > ... > Checking if "c99" compiles: YES > > meson.build:1479:17: ERROR: Can not run test applications in this cross > environment. > ... I have never tried this, but there are instructions for cross-compiling with meson: https://mesonbuild.com/Cross-compilation.html
On Thu, 21 Mar 2024 at 03:56, Peter Eisentraut <peter@eisentraut.org> wrote:
On 20.03.24 22:49, Dave Cramer wrote:
>
>
>
> On Wed, 20 Mar 2024 at 17:11, Andres Freund <andres@anarazel.de
> <mailto:andres@anarazel.de>> wrote:
>
> Hi,
>
> On 2024-03-20 16:14:23 -0400, Dave Cramer wrote:
> > I am getting the following error
> >
> > meson.build:1479:17: ERROR: Can not run test applications in this
> cross
> > environment.
> >
> > Have configured for amd64_x86
> >
> > Running `meson setup --wipe build --prefix=c:\postgres86`
>
> This is not enough information to debug anything. At the very least
> we need
> the exact steps performed to set up the build and
> meson-logs/meson-log.txt
>
> First off this is on an ARM64 machine
>
> The last error from meson-log.txt is
>
> ...
> Checking if "c99" compiles: YES
>
> meson.build:1479:17: ERROR: Can not run test applications in this cross
> environment.
> ...
I have never tried this, but there are instructions for cross-compiling
with meson: https://mesonbuild.com/Cross-compilation.html
It seems that attempting to cross-compile on an ARM machine might be asking too much as the use cases are pretty limited.
So the impetus for this is that folks require 32bit versions of psqlODBC. Unfortunately EDB is no longer distributing a 32 bit windows version.
All I really need is a 32bit libpq. This seems like a much smaller lift. Suggestions ?
Dave
Hi, On 2024-03-21 07:11:23 -0400, Dave Cramer wrote: > It seems that attempting to cross-compile on an ARM machine might be asking > too much as the use cases are pretty limited. It for sure is if you don't even provide the precise commands and logs of a failed run... > So the impetus for this is that folks require 32bit versions of psqlODBC. > Unfortunately EDB is no longer distributing a 32 bit windows version. > > All I really need is a 32bit libpq. This seems like a much smaller lift. > Suggestions ? FWIW, I can cross compile postgres from linux to 32bit windows without an issue. If you really just need a 32bit libpq, that might actually be easier. cd /tmp/ && rm -rf /tmp/meson-w32 && m setup --buildtype debug -Dcassert=true -Db_pch=true --cross-file ~/src/meson/cross/linux-mingw-w64-32bit.txt/tmp/meson-w32 ~/src/postgresql && cd /tmp/meson-w32 && ninja file src/interfaces/libpq/libpq.dll src/interfaces/libpq/libpq.dll: PE32 executable (DLL) (console) Intel 80386, for MS Windows, 19 sections You'd need a windows openssl to actually have a useful libpq, but that should be fairly simple. There are two warnings that I think point to us doing something wrong, but they're not affecting libpq: [1585/1945 42 81%] Linking target src/bin/pgevent/pgevent.dll /usr/bin/i686-w64-mingw32-ld: warning: resolving _DllRegisterServer by linking to _DllRegisterServer@0 Use --enable-stdcall-fixup to disable these warnings Use --disable-stdcall-fixup to disable these fixups /usr/bin/i686-w64-mingw32-ld: warning: resolving _DllUnregisterServer by linking to _DllUnregisterServer@0 Greetings, Andres Freund
Andres,
On Thu, 21 Mar 2024 at 12:51, Andres Freund <andres@anarazel.de> wrote:
Hi,
On 2024-03-21 07:11:23 -0400, Dave Cramer wrote:
> It seems that attempting to cross-compile on an ARM machine might be asking
> too much as the use cases are pretty limited.
It for sure is if you don't even provide the precise commands and logs of a
failed run...
> So the impetus for this is that folks require 32bit versions of psqlODBC.
> Unfortunately EDB is no longer distributing a 32 bit windows version.
>
> All I really need is a 32bit libpq. This seems like a much smaller lift.
> Suggestions ?
FWIW, I can cross compile postgres from linux to 32bit windows without an
issue. If you really just need a 32bit libpq, that might actually be easier.
cd /tmp/ && rm -rf /tmp/meson-w32 && m setup --buildtype debug -Dcassert=true -Db_pch=true --cross-file ~/src/meson/cross/linux-mingw-w64-32bit.txt /tmp/meson-w32 ~/src/postgresql && cd /tmp/meson-w32 && ninja
file src/interfaces/libpq/libpq.dll
src/interfaces/libpq/libpq.dll: PE32 executable (DLL) (console) Intel 80386, for MS Windows, 19 sections
You'd need a windows openssl to actually have a useful libpq, but that should
be fairly simple.
There are two warnings that I think point to us doing something wrong, but they're not affecting libpq:
[1585/1945 42 81%] Linking target src/bin/pgevent/pgevent.dll
/usr/bin/i686-w64-mingw32-ld: warning: resolving _DllRegisterServer by linking to _DllRegisterServer@0
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
/usr/bin/i686-w64-mingw32-ld: warning: resolving _DllUnregisterServer by linking to _DllUnregisterServer@0
Attached correct log file
Dave
Вложения
Hi, On 2024-03-21 13:17:44 -0400, Dave Cramer wrote: > Attached correct log file Hm. So there's something a bit odd: > Build started at 2024-03-21T13:07:08.707715 > Main binary: C:\Program Files\Meson\meson.exe > Build Options: '-Dextra_include_dirs=c:\Program Files\OpenSSL-Win64\include' -Derrorlogs=True '-Dextra_lib_dirs=c:\ProgramFiles\OpenSSL-win64' '-Dprefix=c:\postgres86' > Python system: Windows > The Meson build system > Version: 1.3.1 > Source dir: C:\Users\davec\projects\postgresql > Build dir: C:\Users\davec\projects\postgresql\build > Build type: native build So meson thinks this is a native build, not a cross build. But then later realizes that generated binaries and the current platform aren't the same. And thus errors out. The line numbers don't match my tree, but I think what's failing is the sizeof() check. Which has support for cross builds, but it only uses that (slower) path if it knows that a cross build is being used. I suggest actually telling meson to cross compile. I don't quite know what properties you're going to need, but something like the following (put it in a file, point meson to it wity --cross-file) might give you a start: [properties] needs_exe_wrapper = false [binaries] c = 'cl' cpp = 'cl' ar = 'lib' windres = 'rc' [host_machine] system = 'windows' cpu_family = 'x86_64' cpu = 'x86_64' endian = 'little' Greetings, Andres Freund
On Thu, Mar 21, 2024 at 11:21 AM Andres Freund <andres@anarazel.de> wrote: > Obviously tests can't run in that environment, but building should be > possible. I can e.g. build postgres for x86-64 windows on my linux machine, > but can't run the tests (in theory they could be run with wine, but wine isn't > complete enough to run postgres). For anyone interested in that, the most apparent reason why WINE currently can't run a cross-build of psql.exe or postgres.exe on a Linux/FreeBSD/macOS host is now on their bug list[1] and just needs someone to write an easy patch. I dimly recall there were more subtle things that broke here and there before the relevant change of ours went in, and it would be pretty cool if we could make a list and report 'em... [1] https://bugs.winehq.org/show_bug.cgi?id=56951