microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
23.4k stars 6.47k forks source link

vcpkg_configure_meson does not support cross-compilation #11230

Open traversaro opened 4 years ago

traversaro commented 4 years ago

Describe the bug vcpkg_configure_meson function does not support cross compilation, even for simple header-only libraries that just require to disable sanity checks.

Environment

To Reproduce Steps to reproduce the behavior:

  1. Comment the call to vcpkg_fail_port_install in tomlplusplus's portfile.cmake
  2. ./vcpkg install tomlplusplus:arm64-windows
  3. See error

Expected behavior ./vcpkg install tomlplusplus:arm64-windows should work fine

Failure logs

$ cat buildtrees/tomlplusplus/config-arm64-windows-dbg-out.log
The Meson build system
Version: 0.53.2
Source dir: C:\src\vcpkg\buildtrees\tomlplusplus\src\v1.2.5-6c4dc93a44
Build dir: C:\src\vcpkg\buildtrees\tomlplusplus\arm64-windows-dbg
Build type: native build
Project name: tomlplusplus
Project version: 1.2.5

meson.build:1:0: ERROR: Could not invoke sanity test executable: [WinError 216] This version of %1 is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher.

A full log can be found at C:\src\vcpkg\buildtrees\tomlplusplus\arm64-windows-dbg\meson-logs\meson-log.txt

Additional context Originally emerged in https://github.com/microsoft/vcpkg/pull/10786 .

Neumann-A commented 4 years ago

https://github.com/mesonbuild/meson/blob/master/docs/markdown/Cross-compilation.md

for reference

MVoz commented 4 years ago

@Neumann-A update meson to released 0.54.1 ?))

gvanem commented 4 years ago

There are other issues with vcpkg_configure_meson (whatever that is and what it does).

While doing a vcpkg install fribidi:x86-windows-static --debug, it fails with:

...
    Error code: 1
    See logs for more information:
      F:\gv\VC_project\VCPKG\buildtrees\fribidi\config-x86-windows-static-dbg-out.log

Call Stack (most recent call first):
  scripts/cmake/vcpkg_configure_meson.cmake:161 (vcpkg_execute_required_process)
  ports/fribidi/portfile.cmake:10 (vcpkg_configure_meson)
  scripts/ports.cmake:90 (include)

The config-x86-windows-static-dbg-out.log contains a: meson.build:1:0: ERROR: Executables created by c compiler cl are not runnable.

Oh really!? So I don't think it's only a cross-compilation issue. I'm on Win-10 using MSVC-2019 (x86).

I really need a fribidi to build a working Gtk/Gdk installation. So this is a real show-stopper for me.

janisozaur commented 4 years ago

@gvanem https://github.com/microsoft/vcpkg/issues/11248 was filed for fribidi, but it was just a duplicate of this issue. The problem is meson requires the cross compiled binaries (at least in case of MSVC) to be runnable on host (I fail to see how his could possibly be a valid assumption, but I'm no meson dev). In latest release, 0.54.0 they provide an option to disable this check, presumably to allow cross-compilation with MSVC: https://mesonbuild.com/Release-notes-for-0-54-0.html#skip-sanity-tests-when-cross-compiling

gvanem commented 4 years ago

@janisozaur So I hope the VCPKG folks could help fix Meson and add a new & fixed Meson into VCPKG.

vlj commented 4 years ago

I tried to build glib with meson but it breaks arm64 : https://github.com/microsoft/vcpkg/pull/11477

c72578 commented 4 years ago

update meson to released 0.54.1 ?))

In the meantime, meson has been updated to version 0.54.2 in vcpkg (#11380)

vlj commented 4 years ago

I tried to pass a cross file via --cross when configuring but it seems that meson ignores it, it still triés to execute sanitycheckc

Neumann-A commented 4 years ago

Related https://github.com/mesonbuild/meson/pull/7021 ?

vlj commented 4 years ago

I'm not sure at all since the issue is still that sanitycheckc.exe can't run, which likely means it's an arm64 executable trying to be executed on a x64 machine.

Neumann-A commented 4 years ago

https://github.com/mesonbuild/meson/pull/7190 to actually have control of the option to skip the sanity checks....

vlj commented 4 years ago

By the way does meson work at all with macOS ? When I tried to run a meson build it fails with a message:

  File "/usr/local/bin/meson", line 2
    PYTHONPATH="/usr/local/Cellar/meson/0.54.2/lib/python3.8/site-packages" exec "/usr/local/Cellar/meson/0.54.2/libexe\
c/bin/meson" "$@"

SyntaxError: invalid syntax
orgads commented 3 years ago

I see that meson is already at 0.58. Can this be closed then?

orgads commented 3 years ago

fribidi build still fails on arm64. See https://github.com/orgads/vcpkg-test/actions/runs/1073754458

Neumann-A commented 1 year ago

So to make meson work in cross context you need to pass a cross file via VCPKG_MESON_CROSS_FILE in the triplet which contains information about the exe_wrapper or configure results somehow.

Neumann-A commented 6 months ago

i think this can be closed now.

traversaro commented 6 months ago

Great, thanks to everyone that contributed!