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

Unable to use asio vcpkg dependency for MacOS (cross compilation) with xmake version later than 2.8.2 #4935

Closed
DanEngelbrecht opened this issue Apr 5, 2024 · 14 comments
Labels

Comments

@DanEngelbrecht
Copy link

Xmake Version

2.8.9

Operating System Version and Architecture

macOS Sonoma 14.4.1

Describe Bug

When adding the vcpk::asio dependency to a project it fails to install asio during the config phase when issuing xmake config -v -y --arch=x86_64.
Switching to an older version of xmake (2.8.2) it works as expected.

Expected Behavior

I'd expect it to behave as 2.8.2 and install and link with the asio library.
2.8.2 is the latest version I have found where it works as expected.

Project Configuration

add_requires(
    "vcpkg::asio"
)

set_policy("build.ccache", false)

add_rules("mode.debug", "mode.release")

target("asiotest")
    set_kind("binary")
    add_files("src/main.cpp")

    add_packages(
        "vcpkg::asio")

Additional Information and Error Logs

Output:

> xmake-test % xmake config -v -y --arch=x86_64 
checking for platform ... macosx
checking for Xcode directory ... /Applications/Xcode.app
checking for Codesign Identity of Xcode ... no
checking for SDK version of Xcode for macosx (x86_64) ... 14.4
checking for Minimal target version of Xcode for macosx (x86_64) ... 14.4
checking for zig ... no
checking for zig ... no
checking for nim ... no
checking for nim ... no
checking for unzip ... /usr/bin/unzip
checking for git ... /usr/bin/git
checking for gzip ... /usr/bin/gzip
checking for tar ... /usr/bin/tar
checking for vcpkg ... /Users/dan.engelbrecht/github/microsoft/vcpkg/vcpkg
/Users/dan.engelbrecht/github/microsoft/vcpkg/vcpkg install asio:x64-osx
Computing installation plan...
The following packages are already installed:
    asio:x64-osx@1.29.0
asio:x64-osx is already installed
Total install time: 5.79 us
asio provides CMake targets:

  # this is heuristically generated, and may not be correct
  find_package(asio CONFIG REQUIRED)
  target_link_libraries(main PRIVATE asio::asio)


error: fetch vcpkg::asio-latest failed!
  => install vcpkg::asio latest .. failed
error: install failed!
@waruqi
Copy link
Member

waruqi commented Apr 7, 2024

It works for me, can you try dev version? xmake update -s dev

ruki-2:test ruki$ xmake f -cvD
checking for platform ... macosx
checking for architecture ... x86_64
checking for Xcode directory ... /Applications/Xcode.app
checking for SDK version of Xcode for macosx (x86_64) ... 14.0
checking for Minimal target version of Xcode for macosx (x86_64) ... 14.0
checkinfo: cannot runv(zig version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(zig version), No such file or directory
checking for zig ... no
checking for nim ... /usr/local/bin/nim
checking for unzip ... /usr/bin/unzip
checking for git ... /usr/bin/git
checking for gzip ... /usr/bin/gzip
checking for tar ... /usr/bin/tar
checking for ping ... /sbin/ping
pinging the host(gitee.com) ... 24 ms
pinging the host(gitlab.com) ... 39 ms
pinging the host(github.com) ... 77 ms
updating repositories ..
pulling repository(build-artifacts): https://gitee.com/xmake-mirror/build-artifacts.git to /Users
/ruki/.xmake/repositories/build-artifacts ..
/usr/bin/git -c core.fsmonitor=false pull origin main -f
remote: Enumerating objects: 228, done.
remote: Counting objects: 100% (228/228), done.
remote: Compressing objects: 100% (136/136), done.
remote: Total 175 (delta 100), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (175/175), 45.21 KiB | 328.00 KiB/s, done.
Resolving deltas: 100% (100/100), completed with 20 local objects.
From https://gitee.com/xmake-mirror/build-artifacts
 * branch            main       -> FETCH_HEAD
   8b0a112..c7f4058  main       -> origin/main
Updating 8b0a112..c7f4058
Fast-forward
 packages/c/cpptrace/v0.5.1/manifest.txt       |  92 +++++-----
 packages/g/gdk-pixbuf/2.42.10/manifest.txt    | 202 ++++++++++-----------
 packages/g/glib/2.78.1/manifest.txt           | 202 ++++++++++-----------
 packages/g/grpc/v1.62.1/manifest.txt          |  58 +++---
 packages/j/johnnyengine/1.0.1/manifest.txt    | 330 ++++++++++++++++-----------------
 packages/l/leptonica/1.84.1/manifest.txt      |  40 ++--
 packages/l/libgeotiff/1.7.1/manifest.txt      | 104 +++++------
 packages/o/openjpeg/v2.5.0/manifest.txt       | 392 +++++++++++++++++++--------------------
 packages/o/openscenegraph/3.6.5/manifest.txt  | 290 ++++++++++++++---------------
 packages/p/poppler/21.03.0/manifest.txt       | 424 +++++++++++++++++++++----------------------
 packages/p/protobuf-c/1.3.1/manifest.txt      | 114 ++++++------
 packages/p/protobuf-cpp/26.1/manifest.txt     |  58 +++---
 packages/p/python/3.11.8/manifest.txt         | 124 ++++++-------
 packages/p/python2/2.7.18/manifest.txt        | 346 +++++++++++++++++------------------
 packages/r/re2/2024.04.01/manifest.txt        |  82 +++++++++
 packages/r/robotstxt/2021.11.24/manifest.txt  | 322 ++++++++++++++++----------------
 packages/s/simage/1.8.3/manifest.txt          | 396 ++++++++++++++++++++--------------------
 packages/u/utf8_range/2022.11.15/manifest.txt | 106 +++++------
 packages/z/zmqpb/0.4/manifest.txt             | 106 +++++------
 19 files changed, 1935 insertions(+), 1853 deletions(-)
 create mode 100644 packages/r/re2/2024.04.01/manifest.txt
pulling repository(xmake-repo): https://gitee.com/tboox/xmake-repo.git to /Users/ruki/.xmake/repo
sitories/xmake-repo ..
/usr/bin/git -c core.fsmonitor=false pull origin master -f
remote: Enumerating objects: 346, done.
remote: Counting objects: 100% (346/346), done.
remote: Compressing objects: 100% (216/216), done.
remote: Total 251 (delta 155), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (251/251), 52.09 KiB | 692.00 KiB/s, done.
Resolving deltas: 100% (155/155), completed with 55 local objects.
From https://gitee.com/tboox/xmake-repo
 * branch              master     -> FETCH_HEAD
   c2a7e57a..edd5ebab  master     -> origin/master
Updating c2a7e57a..edd5ebab
Fast-forward
 .github/workflows/ubuntu_clang.yml                          |   4 +-
 packages/a/abseil/xmake.lua                                 |   4 +-
 packages/a/aitoolkit/xmake.lua                              |  17 +---
 packages/a/angelscript/patches/msvc-arm64.patch             |  27 +++++
 packages/a/angelscript/port/xmake.lua                       |  36 +++++++
 packages/a/angelscript/xmake.lua                            |  19 +++-
 packages/a/audiofile/xmake.lua                              |  37 +++++++
 packages/c/cartographer/port/xmake.lua                      |   3 +-
 packages/c/cartographer/xmake.lua                           |   3 +-
 packages/c/chipmunk2d/xmake.lua                             |  30 +++++-
 packages/d/dynareadout/xmake.lua                            |   3 +-
 packages/e/enet6/xmake.lua                                  |   5 +-
 packages/f/fbthrift/xmake.lua                               |   1 +
 packages/f/fizz/xmake.lua                                   |   1 +
 packages/f/fmtlog/xmake.lua                                 |   3 +-
 packages/f/folly/xmake.lua                                  |   5 +-
 packages/g/glaze/xmake.lua                                  |   1 +
 packages/g/grpc/xmake.lua                                   |   2 +-
 packages/j/joltphysics/xmake.lua                            |   1 +
 packages/l/libdwarf/xmake.lua                               |   1 +
 packages/l/libffi/port/xmake.lua                            |  15 ++-
 packages/l/libffi/xmake.lua                                 |   8 +-
 packages/l/libsdl/xmake.lua                                 |   2 +
 packages/l/libtiff/xmake.lua                                |   5 +
 packages/l/libxcomposite/xmake.lua                          |  29 ++++++
 packages/l/lunasvg/xmake.lua                                |   1 +
 packages/m/mapbox_earcut/xmake.lua                          |   1 +
 packages/m/microsoft-proxy/xmake.lua                        |   1 +
 packages/m/mvfst/xmake.lua                                  |   1 +
 packages/m/mxml/xmake.lua                                   |   1 +
 packages/n/nsis/xmake.lua                                   |   3 +-
 packages/o/ozz-animation/xmake.lua                          |   3 +
 packages/p/pdcursesmod/xmake.lua                            | 157 +++++++++++++++--------------
 packages/p/protobuf-cpp/patches/26.1/use_abseil_links.patch |  13 +++
 packages/p/protobuf-cpp/xmake.lua                           |  34 +++++--
 packages/p/proxygen/xmake.lua                               |   1 +
 packages/p/pyincpp/xmake.lua                                |   1 +
 packages/r/robin-map/xmake.lua                              |   1 +
 packages/s/scons/xmake.lua                                  |   1 +
 packages/s/sentry-native/xmake.lua                          |   1 +
 packages/s/simdutf/xmake.lua                                |   4 +-
 packages/t/thread-pool/xmake.lua                            |  19 ++--
 packages/w/wangle/xmake.lua                                 |   1 +
 packages/w/winreg/xmake.lua                                 |   1 +
 44 files changed, 373 insertions(+), 134 deletions(-)
 create mode 100644 packages/a/angelscript/patches/msvc-arm64.patch
 create mode 100644 packages/a/angelscript/port/xmake.lua
 create mode 100644 packages/a/audiofile/xmake.lua
 create mode 100644 packages/l/libxcomposite/xmake.lua
 create mode 100644 packages/p/protobuf-cpp/patches/26.1/use_abseil_links.patch
ok
finding asio from vcpkg ..
checking for brew ... /usr/local/bin/brew
checking for vcpkg::asio ... no
note: install or modify (m) these packages (pass -y to skip confirm)?
in vcpkg:
  -> vcpkg::asio latest
please input: y (y/n/m)

installing asio from vcpkg ..
checking for vcpkg ... /usr/local/bin/vcpkg
/usr/local/bin/vcpkg install asio:x64-osx --debug
[DEBUG] Feature flag 'binarycaching' unset
[DEBUG] Feature flag 'manifests' unset
[DEBUG] Feature flag 'compilertracking' unset
[DEBUG] Feature flag 'registries' unset
[DEBUG] Feature flag 'versions' unset
[DEBUG] Using vcpkg-root: /usr/local/Cellar/vcpkg/2020.11-1/libexec
[DEBUG] Using installed-root: /usr/local/Cellar/vcpkg/2020.11-1/libexec/installed
[DEBUG] Using buildtrees-root: /usr/local/Cellar/vcpkg/2020.11-1/libexec/buildtrees
[DEBUG] Using downloads-root: /usr/local/Cellar/vcpkg/2020.11-1/libexec/downloads
[DEBUG] Using packages-root: /usr/local/Cellar/vcpkg/2020.11-1/libexec/packages
[DEBUG] Using scripts-root: /usr/local/Cellar/vcpkg/2020.11-1/libexec/scripts
Your feedback is important to improve Vcpkg! Please take 3 minutes to complete our survey by runn
ing: vcpkg contact --survey
[DEBUG] Default binary cache path is: /Users/ruki/.cache/vcpkg/archives
Computing installation plan...
[DEBUG] Found path: /usr/local/bin/cmake
[DEBUG] popen("/usr/local/bin/cmake" --version 2>&1)
[DEBUG] cmd_execute_and_stream_data() returned 0 after    65562 us
[DEBUG] popen(/usr/local/bin/cmake -DVCPKG_ROOT_DIR=/usr/local/Cellar/vcpkg/2020.11-1/libexec -DP
ACKAGES_DIR=/usr/local/Cellar/vcpkg/2020.11-1/libexec/packages -DBUILDTREES_DIR=/usr/local/Cellar
/vcpkg/2020.11-1/libexec/buildtrees -D_VCPKG_INSTALLED_DIR=/usr/local/Cellar/vcpkg/2020.11-1/libe
xec/installed -DDOWNLOADS=/usr/local/Cellar/vcpkg/2020.11-1/libexec/downloads -DVCPKG_MANIFEST_IN
STALL=OFF -P /usr/local/Cellar/vcpkg/2020.11-1/libexec/buildtrees/0.vcpkg_tags.cmake 2>&1)
[DEBUG] cmd_execute_and_stream_data() returned 0 after    27192 us
The following packages will be built and installed:
    asio[core]:x64-osx
Detecting compiler hash for triplet x64-osx...
[DEBUG] Found path: /usr/local/bin/ninja
[DEBUG] popen("/usr/local/Cellar/vcpkg/2020.11-1/libexec/downloads/tools/ninja-1.10.1-osx/ninja"
--version 2>&1)
[DEBUG] cmd_execute_and_stream_data() returned 0 after    10928 us
[DEBUG] Found path: /usr/bin/git
[DEBUG] popen("/usr/bin/git" --version 2>&1)
[DEBUG] cmd_execute_and_stream_data() returned 0 after    21221 us
[DEBUG] popen(/usr/local/bin/cmake -DCURRENT_PORT_DIR=/usr/local/Cellar/vcpkg/2020.11-1/libexec/s
cripts/detect_compiler -DCURRENT_BUILDTREES_DIR=/usr/local/Cellar/vcpkg/2020.11-1/libexec/buildtr
ees/detect_compiler -DCURRENT_PACKAGES_DIR=/usr/local/Cellar/vcpkg/2020.11-1/libexec/packages/det
ect_compiler_x64-osx -DCMD=BUILD -DTARGET_TRIPLET=x64-osx -DTARGET_TRIPLET_FILE=/usr/local/Cellar
/vcpkg/2020.11-1/libexec/triplets/x64-osx.cmake -DVCPKG_PLATFORM_TOOLSET=external -DDOWNLOADS=/us
r/local/Cellar/vcpkg/2020.11-1/libexec/downloads -DVCPKG_CONCURRENCY=9 -DGIT=/usr/bin/git -DVCPKG
_ROOT_DIR=/usr/local/Cellar/vcpkg/2020.11-1/libexec -DPACKAGES_DIR=/usr/local/Cellar/vcpkg/2020.1
1-1/libexec/packages -DBUILDTREES_DIR=/usr/local/Cellar/vcpkg/2020.11-1/libexec/buildtrees -D_VCP
KG_INSTALLED_DIR=/usr/local/Cellar/vcpkg/2020.11-1/libexec/installed -DDOWNLOADS=/usr/local/Cella
r/vcpkg/2020.11-1/libexec/downloads -DVCPKG_MANIFEST_INSTALL=OFF -P /usr/local/Cellar/vcpkg/2020.
11-1/libexec/scripts/ports.cmake 2>&1)
[DEBUG] -- Configuring x64-osx-rel
[DEBUG] -- The C compiler identification is AppleClang 15.0.0.15000040
[DEBUG] -- Detecting C compiler ABI info
[DEBUG] -- Detecting C compiler ABI info - done
[DEBUG] -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/Xc
odeDefault.xctoolchain/usr/bin/cc - skipped
[DEBUG] -- Detecting C compile features
[DEBUG] -- Detecting C compile features - done
[DEBUG] -- The CXX compiler identification is AppleClang 15.0.0.15000040
[DEBUG] -- Detecting CXX compiler ABI info
[DEBUG] -- Detecting CXX compiler ABI info - done
[DEBUG] -- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/
XcodeDefault.xctoolchain/usr/bin/c++ - skipped
[DEBUG] -- Detecting CXX compile features
[DEBUG] -- Detecting CXX compile features - done
[DEBUG] -- Configuring done
[DEBUG] -- Generating done
[DEBUG] -- Build files have been written to: /usr/local/Cellar/vcpkg/2020.11-1/libexec/buildtrees
/detect_compiler/x64-osx-rel
[DEBUG]
[DEBUG] #COMPILER_HASH#5007129cae95179eeddd853e94329ca40cc11cbd
[DEBUG] #COMPILER_C_HASH#2759b2ce7a414bcfb5c7fa20ddeb9161f94fa893
[DEBUG] #COMPILER_C_VERSION#15.0.0.15000040
[DEBUG] #COMPILER_C_ID#AppleClang
[DEBUG] #COMPILER_CXX_HASH#2759b2ce7a414bcfb5c7fa20ddeb9161f94fa893
[DEBUG] #COMPILER_CXX_VERSION#15.0.0.15000040
[DEBUG] #COMPILER_CXX_ID#AppleClang
[DEBUG] CMake Warning:
[DEBUG]   Manually-specified variables were not used by the project:
[DEBUG]
[DEBUG]     BUILD_SHARED_LIBS
[DEBUG]     CMAKE_INSTALL_BINDIR
[DEBUG]     CMAKE_INSTALL_LIBDIR
[DEBUG]     VCPKG_CRT_LINKAGE
[DEBUG]     VCPKG_PLATFORM_TOOLSET
[DEBUG]     VCPKG_SET_CHARSET_FLAG
[DEBUG]
[DEBUG]
[DEBUG]
[DEBUG] cmd_execute_and_stream_data() returned 0 after  5245332 us
[DEBUG]
[DEBUG] Detecting compiler hash for triplet x64-osx: 5007129cae95179eeddd853e94329ca40cc11cbd
[DEBUG] <abientries for asio:x64-osx>
[DEBUG]   CMakeLists.txt|c7e51b00e1e613362d910eef681bf7f1a7f12fbd
[DEBUG]   asio-config.cmake|3772e21a6b55def78aa7f93cc0bd17406e11f92c
[DEBUG]   cmake|3.25.3
[DEBUG]   features|core
[DEBUG]   portfile.cmake|33fe2612f3cf355d8b5d6e79a20a2e4ed6112674
[DEBUG]   post_build_checks|2
[DEBUG]   triplet|f51861a20e33a3f2ed220701e7109a88217b5218-94be8c046f9e0595c199a36690d288f7094564
3b-5007129cae95179eeddd853e94329ca40cc11cbd
[DEBUG]   vcpkg.json|eaec0ad17775e33aef4abe4af0e37cc0f2cc61c6
[DEBUG]   vcpkg_configure_cmake|ae0a97eff7f218b68bc4ab1b4bd661107893803e
[DEBUG]   vcpkg_fixup_cmake_targets|799f0da59bbd2e387502be06a30e3d43f2e89b49
[DEBUG]   vcpkg_from_git|f29cbe08f369138581e36c864f9d08465c840e23
[DEBUG]   vcpkg_from_github|1e4d57547e633121a17c0b047a065101aa054671
[DEBUG]   vcpkg_install_cmake|75d1079d6f563d87d08c8c5f63b359377aa19a6e
[DEBUG]   vcpkg_replace_string|99deefc316db487a541ba0b25d6249a0b86e2186
[DEBUG] </abientries>
Starting package 1/1: asio:x64-osx
Building package asio[core]:x64-osx...
Could not locate cached archive: /Users/ruki/.cache/vcpkg/archives/05/0543fcc992fd956801562a3d4b2
792873d7d4983.zip
[DEBUG] popen(/usr/local/bin/cmake -DPORT=asio -DCURRENT_PORT_DIR=/usr/local/Cellar/vcpkg/2020.11
-1/libexec/ports/asio -DVCPKG_USE_HEAD_VERSION=0 -D_VCPKG_NO_DOWNLOADS=0 -D_VCPKG_DOWNLOAD_TOOL=B
UILT_IN -D_VCPKG_EDITABLE=0 -DFEATURES=core "-DALL_FEATURES=coroutine;openssl;regex;" -DCMD=BUILD
 -DTARGET_TRIPLET=x64-osx -DTARGET_TRIPLET_FILE=/usr/local/Cellar/vcpkg/2020.11-1/libexec/triplet
s/x64-osx.cmake -DVCPKG_PLATFORM_TOOLSET=external -DDOWNLOADS=/usr/local/Cellar/vcpkg/2020.11-1/l
ibexec/downloads -DVCPKG_CONCURRENCY=9 -DGIT=/usr/bin/git -DVCPKG_ROOT_DIR=/usr/local/Cellar/vcpk
g/2020.11-1/libexec -DPACKAGES_DIR=/usr/local/Cellar/vcpkg/2020.11-1/libexec/packages -DBUILDTREE
S_DIR=/usr/local/Cellar/vcpkg/2020.11-1/libexec/buildtrees -D_VCPKG_INSTALLED_DIR=/usr/local/Cell
ar/vcpkg/2020.11-1/libexec/installed -DDOWNLOADS=/usr/local/Cellar/vcpkg/2020.11-1/libexec/downlo
ads -DVCPKG_MANIFEST_INSTALL=OFF -P /usr/local/Cellar/vcpkg/2020.11-1/libexec/scripts/ports.cmake
 2>&1)
-- Downloading https://github.com/chriskohlhoff/asio/archive/asio-1-18-0.tar.gz...
-- Extracting source /usr/local/Cellar/vcpkg/2020.11-1/libexec/downloads/chriskohlhoff-asio-asio-
1-18-0.tar.gz
-- Using source at /usr/local/Cellar/vcpkg/2020.11-1/libexec/buildtrees/asio/src/sio-1-18-0-87307
31baf.clean
-- Configuring x64-osx-dbg
-- Configuring x64-osx-rel
-- Building x64-osx-dbg
-- Building x64-osx-rel
-- Installing: /usr/local/Cellar/vcpkg/2020.11-1/libexec/packages/asio_x64-osx/share/asio/asio-co
nfig.cmake
-- Installing: /usr/local/Cellar/vcpkg/2020.11-1/libexec/packages/asio_x64-osx/share/asio/copyrig
ht
[DEBUG] cmd_execute_and_stream_data() returned 0 after  6268186 us
-- Performing post-build validation
-- Performing post-build validation done
[DEBUG] system(cd '/usr/local/Cellar/vcpkg/2020.11-1/libexec/packages/asio_x64-osx' && zip --quie
t -y -r '/usr/local/Cellar/vcpkg/2020.11-1/libexec/buildtrees/asio/x64-osx.zip' *)
[DEBUG] system() returned 0 after 284409 us
Stored binary cache: /Users/ruki/.cache/vcpkg/archives/05/0543fcc992fd956801562a3d4b2792873d7d498
3.zip
Building package asio[core]:x64-osx... done
Installing package asio[core]:x64-osx...
Installing package asio[core]:x64-osx... done
Elapsed time for package asio:x64-osx: 6.776 s

Total elapsed time: 12.07 s

The package asio:x64-osx provides CMake targets:

    find_package(asio CONFIG REQUIRED)
    target_link_libraries(main PRIVATE asio asio::asio)

[DEBUG] ../src/vcpkg/install.cpp(985)
[DEBUG] Exiting after 12192931 us (12187481 us)
finding asio from vcpkg ..
checking for vcpkg::asio ... asio 1.18.0
{
  version = "1.18.0",
  sysincludedirs = {
    "/usr/local/opt/vcpkg/libexec/installed/x64-osx/include"
  }
}

  => install vcpkg::asio latest .. ok
configure
{
    host = macosx
    theme = default
    ccache = true
    plat = macosx
    mode = release
    ndk_stdcxx = true
    buildir = build
    xcode_codesign_identity = Apple Development: waruqi@gmail.com (T3NA4MRVPU)
    xcode = /Applications/Xcode.app
    kind = static
    arch = x86_64
    clean = true
    network = public
    proxy_pac = pac.lua
}
ruki-2:test ruki$ xmake -rv
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/b
in/clang ... ok
checking for the c++ compiler (cxx) ... clang
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/b
in/clang ... ok
checking for flags (-fPIC) ... ok
checking for flags (-fvisibility-inlines-hidden) ... ok
checking for flags (-O3) ... ok
checking for flags (-DNDEBUG) ... ok
[ 50%]: compiling.release src/main.cpp
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -c -
Qunused-arguments -target x86_64-apple-macos14.0 -isysroot /Applications/Xcode.app/Contents/Devel
oper/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -fvisibility=hidden -fvisibility-inl
ines-hidden -O3 -isystem /usr/local/opt/vcpkg/libexec/installed/x64-osx/include -DNDEBUG -o build
/.objs/asiotest/macosx/x86_64/release/src/main.cpp.o src/main.cpp
checking for flags (-MMD -MF) ... ok
checking for flags (-fdiagnostics-color=always) ... ok
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/b
in/clang++ ... ok
checking for the linker (ld) ... clang++
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/b
in/clang++ ... ok
checking for flags (-fPIC) ... ok
[ 75%]: linking.release asiotest
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -o
 build/macosx/x86_64/release/asiotest build/.objs/asiotest/macosx/x86_64/release/src/main.cpp.o -
target x86_64-apple-macos14.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacO
SX.platform/Developer/SDKs/MacOSX14.0.sdk -lz -Wl,-x -Wl,-dead_strip
[100%]: build ok, spent 2.021s
ruki-2:test ruki$

@DanEngelbrecht
Copy link
Author

checking for platform ... macosx
checking for Xcode directory ... /Applications/Xcode.app
checking for Codesign Identity of Xcode ... no
checking for SDK version of Xcode for macosx (x86_64) ... 14.4
checking for Minimal target version of Xcode for macosx (x86_64) ... 14.3
checkinfo: cannot runv(zig version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(zig version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(nim --version), No such file or directory
checking for nim ... no
checkinfo: cannot runv(nim --version), No such file or directory
checking for nim ... no
checking for unzip ... /usr/bin/unzip
checking for git ... /usr/bin/git
checking for gzip ... /usr/bin/gzip
checking for tar ... /usr/bin/tar
note: install or modify (m) these packages (pass -y to skip confirm)?
in vcpkg:
  -> vcpkg::asio latest 
  -> vcpkg::blake3 latest 
  -> vcpkg::cpr latest 
  -> vcpkg::curl latest 
  -> vcpkg::cxxopts 3.0.0 
  -> vcpkg::doctest latest 
  -> vcpkg::fmt latest 
  -> vcpkg::gsl-lite latest 
  -> vcpkg::http-parser latest 
  -> vcpkg::json11 latest 
  -> vcpkg::lua latest 
  -> vcpkg::lz4 latest 
  -> vcpkg::ryml latest 
  -> vcpkg::c4core latest 
  -> vcpkg::robin-map latest 
  -> vcpkg::sol2 latest 
  -> vcpkg::spdlog latest 
  -> vcpkg::xxhash latest 
  -> vcpkg::zlib latest 
  -> vcpkg::openssl latest 
  -> vcpkg::mimalloc latest 
  -> vcpkg::sentry-native latest 
please input: y (y/n/m)
y
installing asio from vcpkg ..
checking for vcpkg ... /Users/stefan/github/vcpkg/vcpkg
/Users/stefan/github/vcpkg/vcpkg install asio:x64-osx --debug
[DEBUG] To include the environment variables in debug output, pass --debug-env
[DEBUG] Trying to load bundleconfig from /Users/stefan/github/vcpkg/vcpkg-bundle.json
[DEBUG] Failed to open: /Users/stefan/github/vcpkg/vcpkg-bundle.json
[DEBUG] Bundle config: readonly=false, usegitregistry=false, embeddedsha=nullopt, deployment=Git, vsversion=nullopt
[DEBUG] Metrics enabled.
[DEBUG] Feature flag 'binarycaching' unset
[DEBUG] Feature flag 'compilertracking' unset
[DEBUG] Feature flag 'registries' unset
[DEBUG] Feature flag 'versions' unset
[DEBUG] Feature flag 'dependencygraph' unset
[DEBUG] Using scripts-root: /Users/stefan/github/vcpkg/scripts
[DEBUG] Using builtin-ports: /Users/stefan/github/vcpkg/ports
[DEBUG] Using installed-root: /Users/stefan/github/vcpkg/installed
[DEBUG] Using buildtrees-root: /Users/stefan/github/vcpkg/buildtrees
[DEBUG] Using packages-root: /Users/stefan/github/vcpkg/packages
[DEBUG] Using vcpkg-root: /Users/stefan/github/vcpkg
[DEBUG] Using scripts-root: /Users/stefan/github/vcpkg/scripts
[DEBUG] Using builtin-registry: /Users/stefan/github/vcpkg/versions
[DEBUG] Using downloads-root: /Users/stefan/github/vcpkg/downloads
Computing installation plan...
The following packages are already installed:
    asio:x64-osx@1.29.0
[DEBUG] Default binary cache path is: /Users/stefan/.cache/vcpkg/archives
asio:x64-osx is already installed
Total install time: 7.96 us
asio provides CMake targets:

  # this is heuristically generated, and may not be correct
  find_package(asio CONFIG REQUIRED)
  target_link_libraries(main PRIVATE asio::asio)

[DEBUG] /Users/runner/work/1/s/src/vcpkg/commands.install.cpp(1402): 
[DEBUG] Time in subprocesses: 0us
[DEBUG] Time in parsing JSON: 639us
[DEBUG] Time in JSON reader: 387us
[DEBUG] Time in filesystem: 1483us
[DEBUG] Time in loading ports: 3435us
[DEBUG] Exiting after 6.29 ms (5177us)

error: .../modules/private/action/require/impl/actions/install.lua:398: fetch vcpkg::asio-latest failed!
stack traceback:
    [C]: in function 'error'
    [@programdir/core/base/os.lua:957]: in function 'raiselevel'
    [@programdir/core/sandbox/modules/utils.lua:143]: in function 'assert'
    [.../modules/private/action/require/impl/actions/install.lua:398]:

  => install vcpkg::asio latest .. failed

.../modules/private/action/require/impl/actions/install.lua:398: fetch vcpkg::asio-latest failed!
stack traceback:
    [C]: in function 'error'
    [@programdir/core/base/os.lua:957]: in function 'raiselevel'
    [@programdir/core/sandbox/modules/utils.lua:143]: in function 'assert'
    [.../modules/private/action/require/impl/actions/install.lua:398]:
if you want to get more verbose errors, please see:
  -> /Users/stefan/zen/build/.packages/v/vcpkg_asio/latest/cache/installdir.failed/logs/install.txt
error: @programdir/core/main.lua:329: @programdir/modules/async/runjobs.lua:338: .../modules/private/action/require/impl/actions/install.lua:474: install failed!
stack traceback:
    [C]: in function 'error'
    [@programdir/core/base/os.lua:957]:
    [.../modules/private/action/require/impl/actions/install.lua:474]: in function 'catch'
    [@programdir/core/sandbox/modules/try.lua:123]: in function 'try'
    [.../modules/private/action/require/impl/actions/install.lua:333]:
    [...modules/private/action/require/impl/install_packages.lua:487]: in function 'jobfunc'
    [@programdir/modules/async/runjobs.lua:256]:

stack traceback:
	[C]: in function 'error'
	@programdir/core/base/os.lua:957: in function 'base/os.raiselevel'
	(...tail calls...)
	@programdir/core/main.lua:329: in upvalue 'cotask'
	@programdir/core/base/scheduler.lua:406: in function <@programdir/core/base/scheduler.lua:399>
	```

@bionicbeagle
Copy link
Contributor

note that it appears the problem only occurs when cross-compiling to an architecture which differs from the host architecture. I.e the most recent log above is from an M2 Mac Mini building for x86, if you build for arm64 it works fine. Similarly, building arm64 on an x86 Mac fails while the native version succeeds.

@waruqi
Copy link
Member

waruqi commented Apr 9, 2024

vcpkg did not find them after installing package, you can debug here.

local infofile = find_file(format("%s_*_%s.list", name, triplet), infodirs)

@bionicbeagle
Copy link
Contributor

It appears like it never reaches that line before erroring out. I can see it getting there on builds that succeed however. Is there a recommended way to debug the code? I simply sprayed some prints here and there to get an idea of the flow for now, but it would be nice to have a way to step through the process.

@waruqi
Copy link
Member

waruqi commented Apr 9, 2024

If this package has been installed, vcpkg/find_package should be able to find it instead of reinstalling it.

Computing installation plan...
The following packages are already installed: <------------------- here
asio:x64-osx@1.29.0
asio:x64-osx is already installed
Total install time: 5.79 us
asio provides CMake targets:
find_package(asio CONFIG REQUIRED)
target_link_libraries(main PRIVATE asio::asio)

I simply sprayed some prints here and there to get an idea of the flow for now, but it would be nice to have a way to step through the process.

just run xmake f -cvD to find this package.

@bionicbeagle
Copy link
Contributor

if I run this command (using xmake v2.8.9+HEAD.cb1b650):

stefan@MacMini zen % xmake f -cvD --arch=x64 --mode=release --yes

the output is as follows. It appears to figure out that the package installed but fails regardless.

checking for platform ... macosx
checking for Xcode directory ... /Applications/Xcode.app
checking for Codesign Identity of Xcode ... no
checking for SDK version of Xcode for macosx (x64) ... 14.4
checking for Minimal target version of Xcode for macosx (x64) ... 14.3
checkinfo: cannot runv(zig version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(zig version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(nim --version), No such file or directory
checking for nim ... no
checkinfo: cannot runv(nim --version), No such file or directory
checking for nim ... no
checking for unzip ... /usr/bin/unzip
checking for git ... /usr/bin/git
checking for gzip ... /usr/bin/gzip
checking for tar ... /usr/bin/tar
installing asio from vcpkg ..
checking for vcpkg ... /Users/stefan/github/vcpkg/vcpkg
/Users/stefan/github/vcpkg/vcpkg install asio:x64-osx --debug
[DEBUG] To include the environment variables in debug output, pass --debug-env
[DEBUG] Trying to load bundleconfig from /Users/stefan/github/vcpkg/vcpkg-bundle.json
[DEBUG] Failed to open: /Users/stefan/github/vcpkg/vcpkg-bundle.json
[DEBUG] Bundle config: readonly=false, usegitregistry=false, embeddedsha=nullopt, deployment=Git, vsversion=nullopt
[DEBUG] Metrics enabled.
[DEBUG] Feature flag 'binarycaching' unset
[DEBUG] Feature flag 'compilertracking' unset
[DEBUG] Feature flag 'registries' unset
[DEBUG] Feature flag 'versions' unset
[DEBUG] Feature flag 'dependencygraph' unset
[DEBUG] Using scripts-root: /Users/stefan/github/vcpkg/scripts
[DEBUG] Using builtin-ports: /Users/stefan/github/vcpkg/ports
[DEBUG] Using installed-root: /Users/stefan/github/vcpkg/installed
[DEBUG] Using buildtrees-root: /Users/stefan/github/vcpkg/buildtrees
[DEBUG] Using packages-root: /Users/stefan/github/vcpkg/packages
[DEBUG] Using vcpkg-root: /Users/stefan/github/vcpkg
[DEBUG] Using scripts-root: /Users/stefan/github/vcpkg/scripts
[DEBUG] Using builtin-registry: /Users/stefan/github/vcpkg/versions
[DEBUG] Using downloads-root: /Users/stefan/github/vcpkg/downloads
Computing installation plan...
The following packages are already installed:
    asio:x64-osx@1.29.0
[DEBUG] Default binary cache path is: /Users/stefan/.cache/vcpkg/archives
asio:x64-osx is already installed
Total install time: 16 us
asio provides CMake targets:

  # this is heuristically generated, and may not be correct
  find_package(asio CONFIG REQUIRED)
  target_link_libraries(main PRIVATE asio::asio)

[DEBUG] /Users/runner/work/1/s/src/vcpkg/commands.install.cpp(1402): 
[DEBUG] Time in subprocesses: 0us
[DEBUG] Time in parsing JSON: 367us
[DEBUG] Time in JSON reader: 273us
[DEBUG] Time in filesystem: 4806us
[DEBUG] Time in loading ports: 5958us
[DEBUG] Exiting after 9.5 ms (8899us)

error: .../modules/private/action/require/impl/actions/install.lua:398: fetch vcpkg::asio-latest failed!```

@waruqi
Copy link
Member

waruqi commented Apr 9, 2024

I know, vcpkg can find it, but we need to make xmake to find it.

local infofile = find_file(format("%s_*_%s.list", name, triplet), infodirs)

when xmake/vcpkg::find_package return nil, xmake will call vcpkg install to reinstall it, then vcpkg report errors, because it has been installed.

so we need fix vcpkg::find_package, vcpkg install should not be called.

fetch vcpkg::asio-latest failed!

vcpkg/find_package return nil

@bionicbeagle
Copy link
Contributor

bionicbeagle commented Apr 9, 2024

ok I think I identified the source of the problem.

I think there is a copy-paste problem here:

-- fetch it from the system and external package sources (disabled for cross-compilation)

It applies the same logic to libraries as it does for tools, and therefore ends up skipping the call to "fetch" the library. Removing the check for is_cross fixes the issue we saw. Should I make a PR, or do you want to handle it yourself?

with that logic changed the config step completes, and the subsequent build also succeeds. I initially had an issue with the build, but realised this was due to my use of --arch=x64 which is not the correct specification in general even though it happened to work with the config step.

@waruqi
Copy link
Member

waruqi commented Apr 10, 2024

It's not a bug, it's just that for cross-compiling, I globally disabled system/3rd library lookups. only xmake packages support it now.

@waruqi waruqi changed the title Unable to use asio vcpkg dependency for MacOS x86_64 with xmake version later than 2.8.2 Unable to use asio vcpkg dependency for MacOS (cross compilation) with xmake version later than 2.8.2 Apr 10, 2024
@waruqi
Copy link
Member

waruqi commented Apr 10, 2024

try #4963

@waruqi waruqi closed this as completed Apr 11, 2024
@DanEngelbrecht
Copy link
Author

DanEngelbrecht commented Apr 12, 2024

@waruqi I tested this with the dev branch and it seems to build fine locally with cross compilation on Mac. Thank you.
I'm wondering when a new release is planned - would be nice to not specify "dev" as our target version for xmake on CI.

@bionicbeagle
Copy link
Contributor

that's great, thanks for helping with this issue @waruqi !

@waruqi
Copy link
Member

waruqi commented Apr 12, 2024

@waruqi I tested this with the dev branch and it seems to build fine locally with cross compilation on Mac. Thank you. I'm wondering when a new release is planned - would be nice to not specify "dev" as our target version for xmake on CI.

It will take about two more weeks or so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants