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

Vcpkg export is trying to export packages from the wrong triplet #24033

Closed
mmahnic opened this issue Apr 8, 2022 · 13 comments
Closed

Vcpkg export is trying to export packages from the wrong triplet #24033

mmahnic opened this issue Apr 8, 2022 · 13 comments
Assignees
Labels
category:question This issue is a question

Comments

@mmahnic
Copy link
Contributor

mmahnic commented Apr 8, 2022

Describe the bug

When exporting packages for the triplet x64-windows-v143, vcpkg wants to include also packages from the triplet x64-windows. Export fails, although the packages it requires are in fact present in x64-windows. These are the "native" packages that are needed to build the packages in the "target" triplet (x64-windows-v143). Vcpkg suggests that these packages should be installed also in x64-windows-v143:

Additional packages (*) need to be exported to complete this operation.
There are packages that have not been built.
To build them, run:
vcpkg install boost-build:x64-windows-v143 boost-modular-build-helper:x64-windows-v143 pkgconf:x64-windows-v143 vcpkg-pkgconfig-get-modules:x64-windows-v143 vcpkg-tool-meson:x64-windows-v143

But at least vcpkg-tool-meson can not be installed:

Error: vcpkg-tool-meson[core] is only supported on 'native'

We use different compilers so we define additional triplets that include the platform toolset. This is the content of the triplet file for x64-windows-v143:

set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)
set(VCPKG_PLATFORM_TOOLSET v143)

Environment

  • OS: Windows
  • Compiler: VC2022, VC2019

To Reproduce
Steps to reproduce the behavior:

  1. ./vcpkg install --triplet x64-windows-v143 boost
  2. Create the package list:
   triplet=x64-windows-v143
   ./vcpkg.exe list --triplet $triplet \
      | gawk "{ print \$1 }" | sed -e "s/:.*$//" | sort | uniq \
      | sed -e "/\[.*\]/d" \
      > $triplet.list

  1. export
      ./vcpkg export --triplet $triplet \
         --nuget --output=exported --nuget-version=123 \
         @$triplet.list \

Expected behavior
A nuget package "exported" is created.

@JackBoosY JackBoosY added the category:vcpkg-bug The issue is with the vcpkg system (including helper scripts in `scripts/cmake/`) label Apr 8, 2022
@JackBoosY
Copy link
Contributor

cc @strega-nil-ms @Neumann-A

The tool port in the dependency should not be exported, or there is some problem here.

@Neumann-A
Copy link
Contributor

I feel like a simple --host-triplet=$triplet is missing here. No reason to CC me for that.

@mmahnic
Copy link
Contributor Author

mmahnic commented Apr 8, 2022

I feel like a simple --host-triplet=$triplet is missing here. No reason to CC me for that.

Adding --host-triplet=x64-windows or --host-triplet=$triplet has no effect.

@cenit
Copy link
Contributor

cenit commented Apr 11, 2022

it should have been --host-triplet=x64-windows-v143 ;)

@mmahnic
Copy link
Contributor Author

mmahnic commented Apr 11, 2022

I have isolated the problem which is not with the export command but with the list command. The command ./vcpkg.exe list --triplet $triplet does not list only packages for the target triplet (x64-windows-v143) but also packages for the host triplet (x64-windows). Therefore the list of packages to export must be filtered:

 triplet=x64-windows-v143
   ./vcpkg.exe list --triplet $triplet \
      | grep $triplet \ 
      ...

Another thing that seems strange to me is that the ./vcpkg export --triplet $triplet also exports packages for the host triplet, which in many cases does not make sense. If we export x86-windows-v143 which we will use on a 32-bit system, the exported x64-windows packages can not be used on the target system.

I am closing this issue since filtering the output from list solved the problem, but I feel that the list and export commands should only work on selected target triplet and ignore anything from the host triplet, unless explicitly requested.

@mmahnic mmahnic closed this as completed Apr 11, 2022
@JackBoosY JackBoosY added category:question This issue is a question and removed category:vcpkg-bug The issue is with the vcpkg system (including helper scripts in `scripts/cmake/`) labels Apr 12, 2022
@JackBoosY
Copy link
Contributor

Fine, I think this should be document.

@cstamatopoulos
Copy link

cstamatopoulos commented Apr 13, 2022

I don't see how this is not a bug. Even specifying the exact triplets brings in the default.

vcpkg.exe export --triplet x86-windows-static-md protobuf:x86-windows-static-md grpc:x86-windows-static-md --nuget --dry-run

The following packages are already built and will be exported:
  * abseil:x86-windows-static-md
  * abseil:x64-windows
  * c-ares:x86-windows-static-md
  * c-ares:x64-windows
  * grpc:x64-windows
    grpc:x86-windows-static-md
  * openssl:x64-windows
  * openssl:x86-windows-static-md
  * protobuf:x64-windows
    protobuf:x86-windows-static-md
  * re2:x64-windows
  * re2:x86-windows-static-md
  * upb:x64-windows
  * upb:x86-windows-static-md
  * vcpkg-cmake:x64-windows
  * vcpkg-cmake-config:x64-windows
  * zlib:x64-windows
  * zlib:x86-windows-static-md

@quasarea
Copy link

@mmahnic could you post the solution for filtering here please?
doing i.e:

.\vcpkg export --nuget --triplet=x86-windows --host-triplet=x86-windows grpc --nuget-id=grpc-x86

makes

The following packages are already built and will be exported:
  * abseil:x86-windows
  * abseil:x64-windows
  * c-ares:x86-windows
  * c-ares:x64-windows
  * grpc:x64-windows
    grpc:x86-windows
  * openssl:x64-windows
  * openssl:x86-windows
  * protobuf:x64-windows
  * protobuf:x86-windows
  * re2:x64-windows
  * re2:x86-windows
  * upb:x64-windows
  * upb:x86-windows
  * vcpkg-cmake:x64-windows
  * vcpkg-cmake-config:x64-windows
  * zlib:x64-windows
  * zlib:x86-windows
Additional packages (*) need to be exported to complete this operation.

and I don't see how I can influence the internal list command at this point. What exactly you expect users do to do to solve it?

@mmahnic
Copy link
Contributor Author

mmahnic commented May 28, 2022

I use this BASH script to export packages:

   triplet="x86-windows-v142"
   ./vcpkg.exe list --triplet $triplet --host-triplet=x64-windows \
      | grep $triplet \
      | gawk "{ print \$1 }" | sed -e "s/:.*$//" | sort | uniq \
      | sed -e "/\[.*\]/d" \
      > xdata/$triplet.list

   ./vcpkg export --triplet $triplet --host-triplet=x64-windows \
         --nuget --output=xdata/$nameprefix --nuget-version=$version \
         @xdata/$triplet.list \
      > xdata/$nupkgname.log

Set the variables nameprefix, version and nupkgname as you wish.

@quasarea
Copy link

quasarea commented May 30, 2022

@mmahnic thanks for this, I was not aware that I can feed triplet.list during export somehow, so it helps to sort it out.
Still, I would disagree with making the issue resolved as the current behavior is quite unexpected.

In my case it does not work as x64 packages are still pulled in:
image

@invy
Copy link

invy commented Oct 6, 2023

Why is this closed?
The filtering won't work if host and target triplets are equals.
Also why?
Why do I need to export vcpkg-*-helpers?
The problem lies withing vcpkg-tool, there is no way (as of now) to distinguish in the export plan between host and target packages and filter them out.
Please reopen or add the issue to vcpkg-tool.

Idealy I would like to build packages for different targets and export them maybe separately. So if I need later to cross-compile somewhere i.e. on x64-linux I would install host packages for x64-linux and target-packages for mingw64 so I'd be able to use tools in my build process.

@sharun
Copy link

sharun commented Oct 29, 2024

We are also facing this issue where when the target is Android OS but the host is MAC_OS(where we are building it), then export tries to export the ones which are needed for the MAC_OS(host) and fails. Can we take a relook at this ?

This is amplified and hence this issue too.
microsoft/vcpkg-tool#1344

@invy
Copy link

invy commented Oct 29, 2024

I ended up writing my own script which exports packages how I need them. (I export in deb format).
Frankly speaking, exporter doesn't belong in the tool. Vcpkg should provide Api (and language bindings for other languages) for people to extend it. Like apt does this...

Vcpkg stores installed packages either in a 'status' file as empty line separated blocks or in separate files (manifest mode).
File lists are in info subdirectory.
Additionally you can parse contents of package manifests to find host-only dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:question This issue is a question
Projects
None yet
Development

No branches or pull requests

8 participants