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

Use vcpkg to install Windows dependencies #98

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

nbyavuz
Copy link
Collaborator

@nbyavuz nbyavuz commented Jun 6, 2024

Now Windows - Server 2019, VS 2019 - Meson & ninja task able to find icu, libxml, libxslt, lz4, openssl, plperl, zlib and zstd.

There are 4 steps to install packages via vcpkg:

1- Create a base Windows image which has dependencies to run vcpkg.

2- Install packages via vcpkg and save & upload the vcpkg cache. Reuse that cache on the next install.

3- Create a Windows image from the base image (step #1). While installing packages via vcpkg, use cache from step #2.

4- Delete Windows base image.

Example run with vcpkg image: https://cirrus-ci.com/build/4816085688516608

Important notes:

Some errors:

  • tcl is not working for now and I did not start to debug it yet. I wanted to discuss the PR first since the differences are quite big.

  • readline: vcpkg is able to install package but build step on Postgres fails.

    [1527/2241] Compiling C object src/bin/psql/psql.exe.p/tab-complete.c.obj
    FAILED: src/bin/psql/psql.exe.p/tab-complete.c.obj 
    "cl" "-Isrc\bin\psql\psql.exe.p" "-Isrc\bin\psql" "-I..\src\bin\psql" "-Isrc\include" "-I..\src\include" "-I..\src\include\port\win32" "-I..\src\include\port\win32_msvc" "-Isrc/interfaces/libpq" "-I..\src\interfaces\libpq" "-IC:/vcpkg/installed/x64-windows/debug/../include" "/MDd" "/FIpostgres_fe_pch.h" "/Yupostgres_fe_pch.h" "/Fpsrc\bin\psql\psql.exe.p\postgres_fe_pch.pch" "/nologo" "/showIncludes" "/utf-8" "/W2" "/Od" "/Zi" "/DWIN32" "/DWINDOWS" "/D__WINDOWS__" "/D__WIN32__" "/D_CRT_SECURE_NO_DEPRECATE" "/D_CRT_NONSTDC_NO_DEPRECATE" "/wd4018" "/wd4244" "/wd4273" "/wd4101" "/wd4102" "/wd4090" "/wd4267" "/FS" "/FdC:\cirrus\build\src\bin\psql\psql.pdb" /Fosrc/bin/psql/psql.exe.p/tab-complete.c.obj "/c" ../src/bin/psql/tab-complete.c
    ../src/bin/psql/tab-complete.c(4023): fatal error C1026: parser stack overflow, program too complex
    
  • libsystemd: can not be installed via vcpkg.

    libxcrypt is only supported on 'linux', which does not match x64-windows. This usually means that there are known build failures, or runtime problems, when building other platforms. To ignore this and attempt to build libxcrypt anyway, rerun vcpkg with `--allow-unsupported`.
    
  • libuuid: can not be installed via vcpkg.

    libuuid is only supported on '!osx & !windows', which does not match x64-windows. This usually means that there are known build failures, or runtime problems, when building other platforms. To ignore this and attempt to build libuuid anyway, rerun vcpkg with `--allow-unsupported`.
    

@nbyavuz nbyavuz requested a review from anarazel June 6, 2024 13:13
@nbyavuz nbyavuz changed the title Use vcpkg to install Windows dependencie Use vcpkg to install Windows dependencies Jun 6, 2024
@nbyavuz
Copy link
Collaborator Author

nbyavuz commented Jun 7, 2024

Having the list of the packages to be installed in two places(.cirrus.yml and windows_install_pg_deps.ps1) is bad. I tried to save the list at top env like:

.cirrus.yml:

env:
  ...
  VCPKG_PACKAGES: gettext icu libxml2 libxslt lz4 openssl pkgconf python3 tcl zlib zstd

but powershell gave this error at:

.\vcpkg.exe install --debug --binarysource=files,${Env:VCPKG_CACHE},readwrite ${Env:VCPKG_PACKAGES} --triplet=x64-windows

and the error message is:

error: expected the end of input parsing a package spec; this usually means the indicated character is not allowed to be in a package spec. Port, triplet, and feature names are all lowercase alphanumeric+hypens.
  on expression: gettext icu libxml2 libxslt lz4 openssl pkgconf python3 tcl zlib zstd

Do you have any idea why?

@macdice
Copy link
Collaborator

macdice commented Jun 7, 2024

For readline, there have been a couple of threads about that:

https://www.postgresql.org/message-id/20230607185458.GA1334487%40rfd.leadboat.com

https://www.postgresql.org/message-id/flat/CACLU5mThm-uCtERMVHMoGED2EPfyS54j83WB20s_BmzVQuMkpg%40mail.gmail.com

One of the problems mentioned there is VA_ARGS_NARGS, but we already fixed that in 3f28bd73.

It is interesting that those two threads mention two different workarounds for C1026. Seems like readline is pretty close to working on Windows, but you should be aware that more work and probably code changes are probably needed!

@anarazel
Copy link
Owner

Having the list of the packages to be installed in two places(.cirrus.yml and windows_install_pg_deps.ps1) is bad. I tried to save the list at top env like:

Why do we need it in .cirrus.yml at all? Can't we just exclusively have it in some image generation script?

@anarazel
Copy link
Owner

Do you have any idea why?

I suspect what might be happening is that powershell ends up passing all the packages as a single argument, and that then can't be interpreted as a package name by vcpkg.

Copy link
Owner

@anarazel anarazel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of stuff in this PR that looks unrelated. Probably needs a rebase?

@nbyavuz nbyavuz force-pushed the windows-deps-vcpkg branch from 41eefd1 to 5b200fe Compare June 11, 2024 14:34
@nbyavuz
Copy link
Collaborator Author

nbyavuz commented Jun 11, 2024

There's a lot of stuff in this PR that looks unrelated. Probably needs a rebase?

Rebased. However, I think these unrelated things may be caused by me 😟.

@nbyavuz nbyavuz force-pushed the windows-deps-vcpkg branch 3 times, most recently from 4a7a3e2 to 0ed122d Compare June 13, 2024 06:59
@nbyavuz nbyavuz requested a review from anarazel June 13, 2024 15:54
@nbyavuz nbyavuz force-pushed the windows-deps-vcpkg branch from 0ed122d to 79a3d48 Compare June 25, 2024 08:43
@nbyavuz
Copy link
Collaborator Author

nbyavuz commented Jun 25, 2024

I updated the PR. Now, the PR does not remove anything. It installs packages by vcpkg and to use these packages:

1- Set PKG_CONFIG_PATH to 'c:\vcpkg\installed\x64-windows\debug\lib\pkgconfig'

2- Remove extra_[lib|include]_dirs for the openssl, otherwise there will be a conflict.

If PKG_CONFIG_PATH is not set, it works as it did before.

@nbyavuz nbyavuz force-pushed the windows-deps-vcpkg branch from 79a3d48 to eda4c30 Compare June 26, 2024 08:55
nbyavuz added 3 commits June 26, 2024 14:01
This task's aim is installing required packages to run vcpkg in next
steps.

- The steps to install required packages are moved from
  windows-ci to windows-base task.

- Cleaning unnecessary files step is moved to
  windows_clean_unnecessary_files.ps1 script because it will be used in
  both tasks.

- Now, windows-ci task depends on windows-base task. So, added another
  matrix to the .cirrus.yml file for '- depends_on'.

- 'Clean up Windows base images' task is added to deleting windows-base
  images. These images will not be used afterwards, so it is safe to
  remove all of them.

- Packer pre-commit check for windows-base task is added to Makefile.
'Build VCPKG Cache' task has two aims.

- Firstly, generate vcpkg cache and upload it to Cirrus CI. So, it can be
  used in future CI runs

- Secondly, export vcpkg files then zip it and upload as artifact. So,
  windows-ci task will download that artifact and will use that instead
  of doing vcpkg install again.

To achieve above:

- 'Build VCPKG Cache' task and 'windows_install_packages_via_vcpkg'
  script is created. This task runs the script and generates cache and
  vcpkg files. Then them to Cirrus CI.

In this commit, this task does nothing. It is just for better
visibility.
In this commit, all of the windows-base, build vcpkg cache and
windows-ci tasks are synced to install packages via vcpkg in end Windows
ci image. The end image includes the dependencies that are installed by
both vcpkg and installers.

To use dependencies that are installed by vcpkg:

1- Remove extra_[lib|include]_dirs for the openssl, otherwise there will
be a conflict.

2- PG_DEPS_['PATH', 'PKG_CONFIG', 'PKG_CONFIG_PATH',
  'EXTRA_INCLUDE_DIRS', 'EXTRA_LIB_DIRS'] are exported as global env
  variablles. Use them accordingly, for example:
    * PATH: ${PG_DEPS_PATH}${PATH}
    * PKG_CONFIG: ${PG_DEPS_PKG_CONFIG}
    * PKG_CONFIG_PATH: ${PG_DEPS_PKG_CONFIG_PATH}
    * -Dextra_include_dirs=%PG_DEPS_EXTRA_INCLUDE_DIRS%
    * -Dextra_lib_dirs=%PG_DEPS_EXTRA_LIB_DIRS%

Summary of the code changes:

- windows_install_packages_via_vcpkg.ps1 script is modified to be called
  from both windows.pkr.hcl and build vcpkg cache task.

- windows-ci task depends on build-vcpkg-cache task now.
@nbyavuz nbyavuz force-pushed the windows-deps-vcpkg branch from eda4c30 to 7b94dc7 Compare June 26, 2024 11:06
@nbyavuz
Copy link
Collaborator Author

nbyavuz commented Jun 26, 2024

PR is updated:

  1. vcpkg is called once, end image uses result of that.
  2. Some packages are installed as static libraries. (copied from Andres' windows-deps-vcpkg-andres branch)
  3. krb5 is built in optimized mode.
  4. PG_DEPS_['PATH', 'PKG_CONFIG', 'PKG_CONFIG_PATH', 'EXTRA_INCLUDE_DIRS', 'EXTRA_LIB_DIRS'] are exported as env variables.

Here is the example CI Run: https://cirrus-ci.com/task/4961222515228672, it is based on Andres' ci-use-vcpkg branch. The only change is last commit, it uses exported env variables from 4).

@nbyavuz nbyavuz requested a review from anarazel June 26, 2024 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants