Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libpq] mingw support #16740

Merged
merged 10 commits into from
Apr 20, 2021
Merged

[libpq] mingw support #16740

merged 10 commits into from
Apr 20, 2021

Conversation

longnguyen2004
Copy link
Contributor

Describe the pull request

I don't have much CPU power to test, @autoantwort can you test for me?

@longnguyen2004 longnguyen2004 marked this pull request as draft March 17, 2021 10:45
@autoantwort
Copy link
Contributor

Yes I will test it

@autoantwort
Copy link
Contributor

Starting package 6/6: libpq:x64-mingw-static
Building package libpq[core,openssl,zlib]:x64-mingw-static...
-- Using community triplet x64-mingw-static. This triplet configuration is not guaranteed to succeed.
-- [COMMUNITY] Loading triplet configuration from: C:\Users\LeanderSchulten\git_projects\Lichtsteuerung.git\vcpkg\triplets\community\x64-mingw-static.cmake
-- Using cached C:/Users/LeanderSchulten/git_projects/Lichtsteuerung.git/vcpkg/downloads/postgresql-12.2.tar.bz2
-- Extracting source C:/Users/LeanderSchulten/git_projects/Lichtsteuerung.git/vcpkg/downloads/postgresql-12.2.tar.bz2
-- Applying patch patches/windows/install.patch
-- Applying patch patches/windows/win_bison_flex.patch
-- Applying patch patches/windows/openssl_exe_path.patch
-- Applying patch patches/windows/Solution.patch
-- Applying patch patches/windows/MSBuildProject_fix_gendef_perl.patch
-- Applying patch patches/windows/msgfmt.patch
-- Applying patch patches/windows/python_lib.patch
-- Applying patch patches/windows/fix-compile-flag-Zi.patch
-- Applying patch patches/windows/MSBuildProject-static-lib.patch
-- Applying patch patches/windows/Mkvcbuild-static-lib.patch
-- Applying patch patches/windows/minimize_install.patch
-- Using source at C:/Users/LeanderSchulten/git_projects/Lichtsteuerung.git/vcpkg/buildtrees/libpq/src/tgresql-12-7e30e0c75d.clean
-- Configuring x64-mingw-static
-- Downloading https://repo.msys2.org/msys/x86_64/autoconf-2.69-5-any.pkg.tar.xz -> msys-autoconf-2.69-5-any.pkg.tar.xz...
-- Downloading https://repo.msys2.org/msys/x86_64/binutils-2.34-4-x86_64.pkg.tar.zst -> msys-binutils-2.34-4-x86_64.pkg.tar.zst...
-- Downloading https://repo.msys2.org/msys/x86_64/libtool-2.4.6-9-x86_64.pkg.tar.xz -> msys-libtool-2.4.6-9-x86_64.pkg.tar.xz...
-- Downloading https://repo.msys2.org/msys/x86_64/file-5.39-1-x86_64.pkg.tar.zst -> msys-file-5.39-1-x86_64.pkg.tar.zst...
-- Downloading https://repo.msys2.org/msys/x86_64/zlib-1.2.11-1-x86_64.pkg.tar.xz -> msys-zlib-1.2.11-1-x86_64.pkg.tar.xz...
-- Downloading https://repo.msys2.org/msys/x86_64/libbz2-1.0.8-2-x86_64.pkg.tar.xz -> msys-libbz2-1.0.8-2-x86_64.pkg.tar.xz...
-- Downloading https://repo.msys2.org/msys/x86_64/m4-1.4.18-2-x86_64.pkg.tar.xz -> msys-m4-1.4.18-2-x86_64.pkg.tar.xz...
-- Downloading https://repo.msys2.org/msys/x86_64/automake-wrapper-11-1-any.pkg.tar.xz -> msys-automake-wrapper-11-1-any.pkg.tar.xz...
-- Downloading https://repo.msys2.org/msys/x86_64/findutils-4.7.0-1-x86_64.pkg.tar.xz -> msys-findutils-4.7.0-1-x86_64.pkg.tar.xz...
-- Using msys root at C:/Users/LeanderSchulten/git_projects/Lichtsteuerung.git/vcpkg/downloads/tools/msys2/9c897ff883069dc3
-- Using msys root at C:/Users/LeanderSchulten/git_projects/Lichtsteuerung.git/vcpkg/downloads/tools/msys2/50864d9fae363d6e
-- Configuring x64-mingw-static-dbg
CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:105 (message):
    Command failed: C:/Users/LeanderSchulten/git_projects/Lichtsteuerung.git/vcpkg/downloads/tools/msys2/9c897ff883069dc3/usr/bin/bash.exe --noprofile --norc --debug -c "V=1 CPP='x86_64-w64-mingw32-gcc.exe -E' CC='x86_64-w64-mingw32-gcc.exe' CC_FOR_BUILD='x86_64-w64-mingw32-gcc.exe' CXX='x86_64-w64-mingw32-g++.exe' AR='ar.exe' LD='ld.exe -verbose' RANLIB='ranlib.exe' OBJDUMP='objdump.exe' STRIP='strip.exe' NM='nm.exe' DLLTOOL='dlltool.exe' CCAS=':' AS=':' ././configure  --with-openssl --with-zlib --without-readline --with-includes=C:/Users/LeanderSchulten/git_projects/Lichtsteuerung.git/build_5_15_2_MinGW_x64-Debug/vcpkg_installed/x64-mingw-static/include gl_cv_double_slash_root=yes ac_cv_func_memmove=yes --disable-silent-rules --verbose --disable-shared --enable-static --with-libraries=C:/Users/LeanderSchulten/git_projects/Lichtsteuerung.git/build_5_15_2_MinGW_x64-Debug/vcpkg_installed/x64-mingw-static/debug/lib --enable-debug --prefix=/C/Users/LeanderSchulten/git_projects/Lichtsteuerung.git/build_5_15_2_MinGW_x64-Debug/vcpkg_installed/x64-mingw-static/debug --bindir='${prefix}'/../tools/libpq/debug/bin --sbindir='${prefix}'/../tools/libpq/debug/sbin --includedir='${prefix}'/../include --datarootdir='${prefix}'/share/libpq"
    Working Directory: C:/Users/LeanderSchulten/git_projects/Lichtsteuerung.git/vcpkg/buildtrees/libpq/x64-mingw-static-dbg
    Error code: 1
    See logs for more information:
      C:\Users\LeanderSchulten\git_projects\Lichtsteuerung.git\vcpkg\buildtrees\libpq\config-x64-mingw-static-dbg-out.log
      C:\Users\LeanderSchulten\git_projects\Lichtsteuerung.git\vcpkg\buildtrees\libpq\config-x64-mingw-static-dbg-err.log

Call Stack (most recent call first):
  scripts/cmake/vcpkg_configure_make.cmake:723 (vcpkg_execute_required_process)
  ports/libpq/portfile.cmake:276 (vcpkg_configure_make)
  scripts/ports.cmake:142 (include)


Error: Building package libpq:x64-mingw-static failed with: BUILD_FAILED
Please ensure you're using the latest portfiles with `.\vcpkg update`, then
submit an issue at https://github.com/Microsoft/vcpkg/issues including:
  Package: libpq:x64-mingw-static
  Vcpkg version: 2021-01-13-d67989bce1043b98092ac45996a8230a059a2d7e

Additionally, attach any relevant sections from the log files above.
-- Running vcpkg install - failed
CMake Error at vcpkg/scripts/buildsystems/vcpkg.cmake:898 (message):
  vcpkg install failed.  See logs for more information:
  C:\Users\LeanderSchulten\git_projects\Lichtsteuerung.git\build_5_15_2_MinGW_x64-Debug\vcpkg-manifest-install.log
Call Stack (most recent call first):
  build_5_15_2_MinGW_x64-Debug/CMakeFiles/3.19.2/CMakeSystem.cmake:6 (include)
  CMakeLists.txt:16 (project)


-- Configuring incomplete, errors occurred!

file:///C:/Users/LeanderSchulten/git_projects/Lichtsteuerung.git/vcpkg/buildtrees/libpq/config-x64-mingw-static-dbg-out.log

checking build system type... x86_64-pc-msys
checking host system type... x86_64-pc-msys
checking which template to use... 

file:///C:/Users/LeanderSchulten/git_projects/Lichtsteuerung.git/vcpkg/buildtrees/libpq/config-x64-mingw-static-dbg-err.log

configure: WARNING: unrecognized options: --disable-silent-rules, --disable-shared, --enable-static
configure: error: 
*******************************************************************
PostgreSQL has apparently not been ported to your platform yet.
To try a manual configuration, look into the src/template directory
for a similar platform and use the '--with-template=' option.

Please also contact <pgsql-bugs@lists.postgresql.org> to see about
rectifying this.  Include the above 'checking host system type...'
line.
*******************************************************************

@longnguyen2004
Copy link
Contributor Author

@autoantwort Added DETERMINE_BUILD_TRIPLET option, please test

@autoantwort
Copy link
Contributor

file:///C:/Users/LeanderSchulten/git_projects/Lichtsteuerung.git/vcpkg/buildtrees/libpq/config-x64-mingw-static-dbg-out.log

checking build system type... x86_64-pc-mingw32
checking host system type... x86_64-pc-mingw32
checking which template to use... win32
checking whether NLS is wanted... no
checking for default port number... 5432
checking for block size... 8kB
checking for segment size... 1GB
checking for WAL block size... 8kB
checking whether the C compiler works... yes
checking for C compiler default output file name... a.exe
checking for suffix of executables... .exe
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether x86_64-w64-mingw32-gcc.exe accepts -g... yes
checking for x86_64-w64-mingw32-gcc.exe option to accept ISO C89... none needed
checking for x86_64-w64-mingw32-gcc.exe option to accept ISO C99... none needed
checking whether we are using the GNU C++ compiler... yes
checking whether x86_64-w64-mingw32-g++.exe accepts -g... yes
checking for gawk... gawk
checking whether x86_64-w64-mingw32-gcc.exe supports -Wdeclaration-after-statement, for CFLAGS... yes
checking whether x86_64-w64-mingw32-gcc.exe supports -Werror=vla, for CFLAGS... yes
checking whether x86_64-w64-mingw32-gcc.exe supports -Wendif-labels, for CFLAGS... yes
checking whether x86_64-w64-mingw32-g++.exe supports -Wendif-labels, for CXXFLAGS... yes
checking whether x86_64-w64-mingw32-gcc.exe supports -Wmissing-format-attribute, for CFLAGS... yes
checking whether x86_64-w64-mingw32-g++.exe supports -Wmissing-format-attribute, for CXXFLAGS... yes
checking whether x86_64-w64-mingw32-gcc.exe supports -Wformat-security, for CFLAGS... yes
checking whether x86_64-w64-mingw32-g++.exe supports -Wformat-security, for CXXFLAGS... yes
checking whether x86_64-w64-mingw32-gcc.exe supports -fno-strict-aliasing, for CFLAGS... yes
checking whether x86_64-w64-mingw32-g++.exe supports -fno-strict-aliasing, for CXXFLAGS... yes
checking whether x86_64-w64-mingw32-gcc.exe supports -fwrapv, for CFLAGS... yes
checking whether x86_64-w64-mingw32-g++.exe supports -fwrapv, for CXXFLAGS... yes
checking whether x86_64-w64-mingw32-gcc.exe supports -fexcess-precision=standard, for CFLAGS... yes
checking whether x86_64-w64-mingw32-g++.exe supports -fexcess-precision=standard, for CXXFLAGS... no
checking whether x86_64-w64-mingw32-gcc.exe supports -funroll-loops, for CFLAGS_VECTOR... yes
checking whether x86_64-w64-mingw32-gcc.exe supports -ftree-vectorize, for CFLAGS_VECTOR... yes
checking whether x86_64-w64-mingw32-gcc.exe supports -Wunused-command-line-argument, for NOT_THE_CFLAGS... no
checking whether x86_64-w64-mingw32-gcc.exe supports -Wformat-truncation, for NOT_THE_CFLAGS... yes
checking whether x86_64-w64-mingw32-gcc.exe supports -Wstringop-truncation, for NOT_THE_CFLAGS... yes
checking whether the C compiler still works... yes
checking how to run the C preprocessor... x86_64-w64-mingw32-gcc.exe -E
checking allow thread-safe client libraries... yes
checking whether to build with ICU support... no
checking whether to build with Tcl... no
checking whether to build Perl modules... no
checking whether to build Python modules... no
checking whether to build with GSSAPI support... no
checking whether to build with PAM support... no
checking whether to build with BSD Authentication support... no
checking whether to build with LDAP support... no
checking whether to build with Bonjour support... no
checking whether to build with OpenSSL support... yes
checking whether to build with SELinux support... no
checking whether to build with systemd support... no
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ld used by GCC... ld.exe -verbose
checking if the linker (ld.exe -verbose) is GNU ld... yes
checking for ranlib... ranlib.exe
checking for strip... strip.exe
checking whether it is possible to strip libraries... yes
checking for ar... ar.exe
checking for dlltool... dlltool.exe
checking for dllwrap... dllwrap
checking for windres... windres
checking for a BSD-compatible install... /usr/bin/install -c
checking for tar... /cygdrive/c/WINDOWS/system32/tar
checking whether ln -s works... no, using cp -pR
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for bison... /cygdrive/c/git-sdk-64/usr/bin/bison
configure: using 
checking for flex... no
checking for perl... /cygdrive/c/Users/LeanderSchulten/git_projects/Lichtsteuerung.git/vcpkg/downloads/tools/perl/5.30.0.1/perl/bin/perl
configure: using perl 5.30.0
checking for a sed that does not truncate output... /usr/bin/sed
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for main in -lm... yes
checking for library containing setproctitle... no
checking for library containing dlopen... no
checking for library containing socket... -lws2_32
checking for library containing shl_load... no
checking for library containing getopt_long... none required
checking for library containing crypt... no
checking for library containing shm_open... no
checking for library containing shm_unlink... no
checking for library containing clock_gettime... none required
checking for library containing fdatasync... no
checking for library containing sched_yield... none required
checking for library containing gethostbyname_r... no
checking for library containing shmget... no
checking for inflate in -lz... yes
checking for library containing CRYPTO_new_ex_data... no

file:///C:/Users/LeanderSchulten/git_projects/Lichtsteuerung.git/vcpkg/buildtrees/libpq/config-x64-mingw-static-dbg-err.log

configure: WARNING: unrecognized options: --disable-silent-rules, --disable-shared, --enable-static
configure: WARNING: *** Include directory C does not exist.
configure: WARNING: *** Include directory /Users/LeanderSchulten/git_projects/Lichtsteuerung.git/build_5_15_2_MinGW_x64-Debug/vcpkg_installed/x64-mingw-static/include does not exist.
configure: WARNING: *** Library directory C does not exist.
configure: WARNING: *** Library directory /Users/LeanderSchulten/git_projects/Lichtsteuerung.git/build_5_15_2_MinGW_x64-Debug/vcpkg_installed/x64-mingw-static/debug/lib does not exist.
configure: WARNING:
*** The installed version of Bison, /cygdrive/c/git-sdk-64/usr/bin/bison, is too old to use with PostgreSQL.
*** Bison version 1.875 or later is required, but this is .
configure: WARNING:
*** Without Bison you will not be able to build PostgreSQL from Git nor
*** change any of the parser definition files.  You can obtain Bison from
*** a GNU mirror site.  (If you are using the official distribution of
*** PostgreSQL then you do not need to worry about this, because the Bison
*** output is pre-generated.)
configure: WARNING:
*** Without Flex you will not be able to build PostgreSQL from Git nor
*** change any of the scanner definition files.  You can obtain Flex from
*** a GNU mirror site.  (If you are using the official distribution of
*** PostgreSQL then you do not need to worry about this because the Flex
*** output is pre-generated.)
configure: error: library 'eay32' or 'crypto' is required for OpenSSL

@NancyLi1013 NancyLi1013 self-assigned this Mar 18, 2021
@NancyLi1013 NancyLi1013 added the category:port-feature The issue is with a library, which is requesting new capabilities that didn’t exist label Mar 18, 2021
@longnguyen2004
Copy link
Contributor Author

OpenSSL now works, but zlib isn't working, due to the configure script only checking for -lz, not -lzlib and -lzlibd. I've reported this to upstream, and I'll leave this PR here until it's fixed.

@NancyLi1013
Copy link
Contributor

Please ping me if this PR is ready for review @longnguyen2004.

@longnguyen2004
Copy link
Contributor Author

Please ping me if this PR is ready for review @longnguyen2004.

Sure, I'm waiting for upstream response to this.

@longnguyen2004
Copy link
Contributor Author

No responses from upstream, I'll have to work on this then (curse autotools...)

@longnguyen2004 longnguyen2004 force-pushed the libpq-mingw branch 2 times, most recently from ad3b5c6 to 03ab510 Compare April 6, 2021 13:59
@longnguyen2004
Copy link
Contributor Author

@autoantwort Rebased on latest master and added patch, please test.

@autoantwort
Copy link
Contributor

Now I get

pg_strong_random.c:39:19: warning: 'hProvider' defined but not used [-Wunused-variable]
 static HCRYPTPROV hProvider = 0;
                   ^~~~~~~~~
pg_strong_random.c:39:19: warning: 'hProvider' defined but not used [-Wunused-variable]
 static HCRYPTPROV hProvider = 0;
                   ^~~~~~~~~
C:/Qt/Tools/mingw810_64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lpgcommon
C:/Qt/Tools/mingw810_64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lpgport
collect2.exe: error: ld returned 1 exit status
make: *** [../../../src/Makefile.shlib:391: libpq.dll] Error 1
make: *** [Makefile:20: all] Error 2

@longnguyen2004
Copy link
Contributor Author

For some reason libpgcommon.a and libpgport.a are not produced, I'm trying to find out why.

@longnguyen2004
Copy link
Contributor Author

make install on macOS isn't working properly, does anyone know why?

@autoantwort
Copy link
Contributor

make install on macOS isn't working properly, does anyone know why?

maybe pipeline rerun fixes the problem. You can do it with git commit --allow-empty -m "Trigger Build"

@longnguyen2004
Copy link
Contributor Author

x64-osx make install output:
make: 'install' is up to date.
What?
Guess I'll do a rerun, and also replicate the custom Makefile functionality with vcpkg_install_make().

@longnguyen2004
Copy link
Contributor Author

Everything's working, except for osx, I don't know what happened.

@longnguyen2004 longnguyen2004 force-pushed the libpq-mingw branch 2 times, most recently from b3574f8 to 70ec9b1 Compare April 9, 2021 16:32
@longnguyen2004
Copy link
Contributor Author

Note on static library: PostgreSQL doesn't support static linkage anymore, should we change the manifest so that static triplets aren't supported?

@Neumann-A
Copy link
Contributor

Note on static library: PostgreSQL doesn't support static linkage anymore, should we change the manifest so that static triplets aren't supported?

Source?

@longnguyen2004
Copy link
Contributor Author

Source?

https://www.postgresql.org/message-id/25000.1499872310%40sss.pgh.pa.us

Also, it's pretty evident that static linkage isn't supported, due to the lack of --enable-shared/static flag.

@Neumann-A
Copy link
Contributor

Neumann-A commented Apr 9, 2021

Also, it's pretty evident that static linkage isn't supported, due to the lack of --enable-shared/static flag.

without having a configure.ac script i would never expect the availability of default flags.

https://github.com/postgres/postgres has the actual configure.ac so it would be very easy to patch those flags back in especially since they did not give a good reason why to not have a static library (except that you cannot update the code if statically linked.)
Furthermore using the github mirror it might be possible to run vcpkg_configure_make on libpq on windows.

If libpq becomes dynamic only please remove libpq as a default feature from qt5-base because otherwise a lot of dependent ports will no longer be tested in CI

https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=381a9ed66d8a601eb972be172e7251ca7f0e9d78

@longnguyen2004
Copy link
Contributor Author

They seems to be heading towards no static libraries, so I wouldn't be surprised if this does happen in the future. We're using the undocumented all-static-lib target anyway, so there's no guarantee that it'll work in the future. Anyway, this is just a note, and is unrelated to this PR.

@Neumann-A
Copy link
Contributor

They seems to be heading towards no static libraries

https://github.com/postgres/postgres/blob/41badeaba8beee7648ebe7923a41c04f1f3cb302/src/Makefile.shlib#L13-L16

https://github.com/postgres/postgres/blob/41badeaba8beee7648ebe7923a41c04f1f3cb302/src/Makefile.shlib#L47

https://github.com/postgres/postgres/blob/41badeaba8beee7648ebe7923a41c04f1f3cb302/src/Makefile.shlib#L270-L272

It is just a target based static/shared library build instead a configure time selection. Probably because they want to be able to build both at the same time. It does not seem to be heading that direction because it has basically always been that way.

@JackBoosY JackBoosY added info:reviewed Pull Request changes follow basic guidelines and removed requires:author-response labels Apr 13, 2021
@NancyLi1013
Copy link
Contributor

Let's wait for the test result from @autoantwort.

@NancyLi1013 NancyLi1013 removed the info:reviewed Pull Request changes follow basic guidelines label Apr 13, 2021
@autoantwort
Copy link
Contributor

autoantwort commented Apr 13, 2021

Maybe I have done something wrong, but I get the following error:

Starting package 6/6: libpq:x64-mingw-static
Building package libpq[core,openssl,zlib]:x64-mingw-static...
-- Using community triplet x64-mingw-static. This triplet configuration is not guaranteed to succeed.
-- [COMMUNITY] Loading triplet configuration from: C:\Users\LeanderSchulten\git_projects\Lichtsteuerung.git\vcpkg\triplets\community\x64-mingw-static.cmake
-- Using cached C:/Users/LeanderSchulten/git_projects/Lichtsteuerung.git/vcpkg/downloads/postgresql-12.2.tar.bz2
-- Extracting source C:/Users/LeanderSchulten/git_projects/Lichtsteuerung.git/vcpkg/downloads/postgresql-12.2.tar.bz2
-- Applying patch patches/windows/install.patch
-- Applying patch patches/windows/win_bison_flex.patch
-- Applying patch patches/windows/openssl_exe_path.patch
-- Applying patch patches/windows/Solution.patch
-- Applying patch patches/windows/MSBuildProject_fix_gendef_perl.patch
-- Applying patch patches/windows/msgfmt.patch
-- Applying patch patches/windows/python_lib.patch
-- Applying patch patches/windows/fix-compile-flag-Zi.patch
-- Applying patch patches/mingw/additional-zlib-names.patch
-- Applying patch patches/windows/MSBuildProject-static-lib.patch
-- Applying patch patches/windows/Mkvcbuild-static-lib.patch
-- Applying patch patches/windows/minimize_install.patch
-- Using source at C:/Users/LeanderSchulten/git_projects/Lichtsteuerung.git/vcpkg/buildtrees/libpq/src/tgresql-12-afa51858f2.clean
-- Configuring x64-mingw-static
-- Using msys root at C:/Users/LeanderSchulten/git_projects/Lichtsteuerung.git/vcpkg/downloads/tools/msys2/d589ebc2087b2b2c
-- Using msys root at C:/Users/LeanderSchulten/git_projects/Lichtsteuerung.git/vcpkg/downloads/tools/msys2/50864d9fae363d6e
-- Configuring x64-mingw-static-dbg
CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:105 (message):
    Command failed: C:/Users/LeanderSchulten/git_projects/Lichtsteuerung.git/vcpkg/downloads/tools/msys2/d589ebc2087b2b2c/usr/bin/bash.exe --noprofile --norc --debug -c "V=1 CPP='x86_64-w64-mingw32-gcc.exe -E' CC='x86_64-w64-mingw32-gcc.exe' CC_FOR_BUILD='x86_64-w64-mingw32-gcc.exe' CXX='x86_64-w64-mingw32-g++.exe' AR='ar.exe' LD='ld.exe -verbose' RANLIB='ranlib.exe' OBJDUMP='objdump.exe' STRIP='strip.exe' NM='nm.exe' DLLTOOL='dlltool.exe' CCAS=':' AS=':' ././configure --build=x86_64-pc-mingw32 --with-openssl --with-zlib --without-readline gl_cv_double_slash_root=yes ac_cv_func_memmove=yes --disable-silent-rules --verbose --disable-shared --enable-static --enable-debug --prefix=/C/Users/LeanderSchulten/git_projects/Lichtsteuerung.git/build_5_15_2_MinGW_x64-Debug/vcpkg_installed/x64-mingw-static/debug --bindir='${prefix}'/../tools/libpq/debug/bin --sbindir='${prefix}'/../tools/libpq/debug/sbin --includedir='${prefix}'/../include --datarootdir='${prefix}'/share/libpq"
    Working Directory: C:/Users/LeanderSchulten/git_projects/Lichtsteuerung.git/vcpkg/buildtrees/libpq/x64-mingw-static-dbg
    Error code: 1
    See logs for more information:
      C:\Users\LeanderSchulten\git_projects\Lichtsteuerung.git\vcpkg\buildtrees\libpq\config-x64-mingw-static-dbg-out.log
      C:\Users\LeanderSchulten\git_projects\Lichtsteuerung.git\vcpkg\buildtrees\libpq\config-x64-mingw-static-dbg-err.log

Call Stack (most recent call first):
  scripts/cmake/vcpkg_configure_make.cmake:749 (vcpkg_execute_required_process)
  ports/libpq/portfile.cmake:279 (vcpkg_configure_make)
  scripts/ports.cmake:142 (include)


Error: Building package libpq:x64-mingw-static failed with: BUILD_FAILED

config-x64-mingw-static-dbg-err.log:

configure: WARNING: unrecognized options: --disable-silent-rules, --disable-shared, --enable-static
configure: WARNING:
*** The installed version of Bison, /cygdrive/c/git-sdk-64/usr/bin/bison, is too old to use with PostgreSQL.
*** Bison version 1.875 or later is required, but this is .
configure: WARNING:
*** Without Bison you will not be able to build PostgreSQL from Git nor
*** change any of the parser definition files.  You can obtain Bison from
*** a GNU mirror site.  (If you are using the official distribution of
*** PostgreSQL then you do not need to worry about this, because the Bison
*** output is pre-generated.)
configure: WARNING:
*** Without Flex you will not be able to build PostgreSQL from Git nor
*** change any of the scanner definition files.  You can obtain Flex from
*** a GNU mirror site.  (If you are using the official distribution of
*** PostgreSQL then you do not need to worry about this because the Flex
*** output is pre-generated.)
configure: error: library 'eay32' or 'crypto' is required for OpenSSL

config-x64-mingw-static-dbg-out.log
checking build system type... x86_64-pc-mingw32
checking host system type... x86_64-pc-mingw32
checking which template to use... win32
checking whether NLS is wanted... no
checking for default port number... 5432
checking for block size... 8kB
checking for segment size... 1GB
checking for WAL block size... 8kB
checking whether the C compiler works... yes
checking for C compiler default output file name... a.exe
checking for suffix of executables... .exe
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether x86_64-w64-mingw32-gcc.exe accepts -g... yes
checking for x86_64-w64-mingw32-gcc.exe option to accept ISO C89... none needed
checking for x86_64-w64-mingw32-gcc.exe option to accept ISO C99... none needed
checking whether we are using the GNU C++ compiler... yes
checking whether x86_64-w64-mingw32-g++.exe accepts -g... yes
checking for gawk... gawk
checking whether x86_64-w64-mingw32-gcc.exe supports -Wdeclaration-after-statement, for CFLAGS... yes
checking whether x86_64-w64-mingw32-gcc.exe supports -Werror=vla, for CFLAGS... yes
checking whether x86_64-w64-mingw32-gcc.exe supports -Wendif-labels, for CFLAGS... yes
checking whether x86_64-w64-mingw32-g++.exe supports -Wendif-labels, for CXXFLAGS... yes
checking whether x86_64-w64-mingw32-gcc.exe supports -Wmissing-format-attribute, for CFLAGS... yes
checking whether x86_64-w64-mingw32-g++.exe supports -Wmissing-format-attribute, for CXXFLAGS... yes
checking whether x86_64-w64-mingw32-gcc.exe supports -Wformat-security, for CFLAGS... yes
checking whether x86_64-w64-mingw32-g++.exe supports -Wformat-security, for CXXFLAGS... yes
checking whether x86_64-w64-mingw32-gcc.exe supports -fno-strict-aliasing, for CFLAGS... yes
checking whether x86_64-w64-mingw32-g++.exe supports -fno-strict-aliasing, for CXXFLAGS... yes
checking whether x86_64-w64-mingw32-gcc.exe supports -fwrapv, for CFLAGS... yes
checking whether x86_64-w64-mingw32-g++.exe supports -fwrapv, for CXXFLAGS... yes
checking whether x86_64-w64-mingw32-gcc.exe supports -fexcess-precision=standard, for CFLAGS... yes
checking whether x86_64-w64-mingw32-g++.exe supports -fexcess-precision=standard, for CXXFLAGS... no
checking whether x86_64-w64-mingw32-gcc.exe supports -funroll-loops, for CFLAGS_VECTOR... yes
checking whether x86_64-w64-mingw32-gcc.exe supports -ftree-vectorize, for CFLAGS_VECTOR... yes
checking whether x86_64-w64-mingw32-gcc.exe supports -Wunused-command-line-argument, for NOT_THE_CFLAGS... no
checking whether x86_64-w64-mingw32-gcc.exe supports -Wformat-truncation, for NOT_THE_CFLAGS... yes
checking whether x86_64-w64-mingw32-gcc.exe supports -Wstringop-truncation, for NOT_THE_CFLAGS... yes
checking whether the C compiler still works... yes
checking how to run the C preprocessor... x86_64-w64-mingw32-gcc.exe -E
checking allow thread-safe client libraries... yes
checking whether to build with ICU support... no
checking whether to build with Tcl... no
checking whether to build Perl modules... no
checking whether to build Python modules... no
checking whether to build with GSSAPI support... no
checking whether to build with PAM support... no
checking whether to build with BSD Authentication support... no
checking whether to build with LDAP support... no
checking whether to build with Bonjour support... no
checking whether to build with OpenSSL support... yes
checking whether to build with SELinux support... no
checking whether to build with systemd support... no
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ld used by GCC... ld.exe -verbose
checking if the linker (ld.exe -verbose) is GNU ld... yes
checking for ranlib... ranlib.exe
checking for strip... strip.exe
checking whether it is possible to strip libraries... yes
checking for ar... ar.exe
checking for dlltool... dlltool.exe
checking for dllwrap... dllwrap
checking for windres... windres
checking for a BSD-compatible install... /usr/bin/install -c
checking for tar... /cygdrive/c/WINDOWS/system32/tar
checking whether ln -s works... no, using cp -pR
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for bison... /cygdrive/c/git-sdk-64/usr/bin/bison
configure: using 
checking for flex... no
checking for perl... /cygdrive/c/Users/LeanderSchulten/git_projects/Lichtsteuerung.git/vcpkg/downloads/tools/perl/5.30.0.1/perl/bin/perl
configure: using perl 5.30.0
checking for a sed that does not truncate output... /usr/bin/sed
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for main in -lm... yes
checking for library containing setproctitle... no
checking for library containing dlopen... no
checking for library containing socket... -lws2_32
checking for library containing shl_load... no
checking for library containing getopt_long... none required
checking for library containing crypt... no
checking for library containing shm_open... no
checking for library containing shm_unlink... no
checking for library containing clock_gettime... none required
checking for library containing fdatasync... no
checking for library containing sched_yield... none required
checking for library containing gethostbyname_r... no
checking for library containing shmget... no
checking for library containing inflate... -lzlibd
checking for library containing CRYPTO_new_ex_data... no

@longnguyen2004
Copy link
Contributor Author

@autoantwort libcrypt32.a need to be linked explicitly, will add a patch.

@longnguyen2004
Copy link
Contributor Author

@autoantwort Should be good now.

@JackBoosY
Copy link
Contributor

Depends on #17277.

@JackBoosY JackBoosY added the depends:different-pr This PR or Issue depends on a PR which has been filed label Apr 14, 2021
@autoantwort
Copy link
Contributor

@autoantwort Should be good now.

Works now with x64-mingw-static 🎉 Thank you for your effort!

@JackBoosY JackBoosY removed the depends:different-pr This PR or Issue depends on a PR which has been filed label Apr 15, 2021
@NancyLi1013 NancyLi1013 added the info:reviewed Pull Request changes follow basic guidelines label Apr 15, 2021
@dg0yt
Copy link
Contributor

dg0yt commented Apr 17, 2021

This didn't build for me on Windows/MSYS2, neither locally (MINGW64 terminal) nor on Azure Pipelines (MINGW64 bash from Microsoft image). It failed in configure with very few messages:

/usr/bin/expr: syntax error: unexpected argument '.dir-locals.el'
/usr/bin/expr: syntax error: unexpected argument '.dir-locals.el'
/usr/bin/expr: syntax error: unexpected argument '.dir-locals.el'
configure: error: invalid variable name: `0'

It is related to configure using expr with .* patterns to match --with... arguments. These patterns are expanded by the shell (-> .dir.locals.el) instead of being passed to expr. However, the issue didn't occur with other ports, or directly in bash.

It took me a while to locate the issue. It is triggered by vcpkg's acquisition of perl (from MSYS2), and prepending perl.exe's directory to the PATH. I don't know why things go wrong with bash or expr at this point, but I have more evidence of how things fail when /usr/bin is inserted before /mingw64/bin'. And vcpkg_configure_make` already use another approach: inserting paths before System32:

# This inserts msys before system32 (which masks sort.exe and find.exe) but after MSVC (which avoids masking link.exe)
string(REPLACE ";$ENV{SystemRoot}\\System32;" "${APPEND_ENV};${MSYS_ROOT}/usr/bin;$ENV{SystemRoot}\\System32;" NEWPATH "$ENV{PATH}")

I'm not objecting to moving this PR forward. But I feel like this port might need more revisions. I'm also skeptical of applying different sets of patches depending on the target. This needs different source dirs as soon as you want to build for a different target. (Hello Android!)

@dg0yt
Copy link
Contributor

dg0yt commented Apr 17, 2021

This didn't build for me on Windows/MSYS2, neither locally (MINGW64 terminal) nor on Azure Pipelines (MINGW64 bash from Microsoft image).

This scoping was quite accurate:
The problem occurs only when running vcpkg from MSYS2's bash.
From Windows' Command prompt, with only the physical locations of /mingw64/bin and /usr/bin prepended to PATH, the port builds properly (and significantly faster, but I need to verify this).

ports/libpq/portfile.cmake Outdated Show resolved Hide resolved
@longnguyen2004
Copy link
Contributor Author

I don't really know what's the current support with running vcpkg inside MSYS2 bash, since I only test with a standalone toolchain (llvm-mingw).
Also, you don't need to add MSYS2 /usr/bin into PATH, since vcpkg downloads its own MSYS2.

@dg0yt
Copy link
Contributor

dg0yt commented Apr 17, 2021

Also, you don't need to add MSYS2 /usr/bin into PATH, since vcpkg downloads its own MSYS2.

I can confirm this. I also had one build in that configuration. I added /usr/bin because I wanted to know if it breaks in the same way like when running from MSYS2 bash.

@longnguyen2004
Copy link
Contributor Author

Yeah I guess it only happens when running vcpkg in bash, I haven't tested it thoroughly.

@dg0yt
Copy link
Contributor

dg0yt commented Apr 19, 2021

Okay for me now.
The problem with MSYS2 bash is a more general one. I will add a section on the mingw documentation PR.

@dg0yt dg0yt mentioned this pull request Apr 19, 2021
@strega-nil strega-nil merged commit 818cf25 into microsoft:master Apr 20, 2021
@strega-nil
Copy link
Contributor

Thanks so much y'all, especially @longnguyen2004

@longnguyen2004 longnguyen2004 deleted the libpq-mingw branch April 20, 2021 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:port-feature The issue is with a library, which is requesting new capabilities that didn’t exist info:reviewed Pull Request changes follow basic guidelines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[libpq] build failure (linux -> windows cross compile)
7 participants