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

toolchains configuration option in add_requires does not take effect on Windows. #5069

Closed
JX-Master opened this issue May 7, 2024 · 9 comments
Labels
Milestone

Comments

@JX-Master
Copy link

Xmake Version

2.9.1

Operating System Version and Architecture

Windows 10, clang-cl

Describe Bug

On xmake.lua, I set one specific package d3d12-memory-allocator to be built using msvc like so:

add_requires("d3d12-memory-allocator", {configs = {toolchains = "msvc"}})

The full xmake script can be seen here: https://github.com/JX-Master/LunaSDK/blob/0218180058a1cc068e523cec5f3e17294e4938ef/xmake.lua#L80C5-L80C78

Then I configure the project using the following commands:

xmake f --mode=debug --arch=x64 --toolchain=clang-cl -c -y -v 

It seems that make will still use clang-cl to build d3d12-memory-allocator instead of msvc, even if the toolchain is explicitly specified, which caues compile errors. The full error log can be seen here:

https://github.com/JX-Master/LunaSDK/actions/runs/8979206373/job/24660823551

Expected Behavior

The specified package, d3d12-memory-allocator, should be compiled using msvc instead of clang-cl according to the configuation, even if the host project itself is built using clang-cl.

Project Configuration

https://github.com/JX-Master/LunaSDK/blob/0218180058a1cc068e523cec5f3e17294e4938ef/xmake.lua#L80C5-L80C78

Additional Information and Error Logs

https://github.com/JX-Master/LunaSDK/actions/runs/8979206373/job/24660823551

@JX-Master JX-Master added the bug label May 7, 2024
@waruqi
Copy link
Member

waruqi commented May 8, 2024

It works for me.

$ xmake f --mode=debug --arch=x64 --toolchain=clang-cl -c -v
checking for d3d12-memory-allocator ... no
note: install or modify (m) these packages (pass -y to skip confirm)?
in xmake-repo:
  -> d3d12-memory-allocator v2.0.1 [toolchains:"msvc", runtimes:"MT"]          <------ still msvc
please input: y (y/n/m)

@waruqi
Copy link
Member

waruqi commented May 8, 2024

no toolchain configs now. https://github.com/JX-Master/LunaSDK/blob/a43a6711242abf8658d407c53d0889bb6a746e98/xmake.lua#L80

And I add msvc, it still works for me.

    add_requires("d3d12-memory-allocator", {configs = {toolchains = "msvc"}})
PS C:\Users\wangrunqing\Downloads\LunaSDK> xmake f --mode=debug --contract_assertion=y --thread_safe_assertion=y --arch=x64 --toolchain=clang-cl -c -v --rhi_debug=y --rhi_api=D3D12 --shared=y
> checking for c links(d3d12-memory-allocator)
> checking for c snippet(find_package/d3d12-memory-allocator)
checking for d3d12-memory-allocator ... no
note: install or modify (m) these packages (pass -y to skip confirm)?
in xmake-repo:
  -> miniaudio 0.11.21
  -> stb 2023.12.15
  -> spirv-cross 1.3.268+0 [runtimes:"MT", toolchains:"clang-cl"]
  -> glfw 3.4 [runtimes:"MT", toolchains:"clang-cl"]
  -> d3d12-memory-allocator v2.0.1 [runtimes:"MT", toolchains:"msvc"] <-------------- msvc
please input: y (y/n/m)

@waruqi
Copy link
Member

waruqi commented May 8, 2024

I tried your project, it works on ci too.

https://github.com/waruqi/LunaSDK/actions/runs/8997613472

patch

waruqi/LunaSDK@f53ba18

@JX-Master
Copy link
Author

I tried your project, it works on ci too.

https://github.com/waruqi/LunaSDK/actions/runs/8997613472

The main branch of LunaSDK is locked to Xmake v2.8.9 to prevent CI failure. It can be seen here:

https://github.com/waruqi/LunaSDK/actions/runs/8997613472/job/24716094811

Run xmake-io/github-action-setup-xmake@v1
  with:
    xmake-version: 2.8.9
    actions-cache-folder: .xmake-cache-W19
  env:
    XMAKE_GLOBALDIR: D:\a\LunaSDK/xmake-global
Selected xmake v2.8.9 (commit: cb1b6505)
Selected xmake v2.9.1 (commit: 0c79f616)
download xmake v2.8.9
  downloading from https://github.com/xmake-io/xmake/releases/download/v2.8.9/xmake-v2.8.9.win64.exe
  downloaded to D:\a\_temp\fcdb7acf-acdc-448e-ae39-bf346b4a5ca3.exe
install xmake v2.8.9
  installing to C:\Users\RUNNER~1\AppData\Local\Temp\xmake-cb1b65054db2a2917ef3998d9f0b2f72a8d99e54
  D:\a\_temp\fcdb7acf-acdc-448e-ae39-bf346b4a5ca3.exe /NOADMIN /S /D=C:\Users\RUNNER~1\AppData\Local\Temp\xmake-cb1b65054db2a2917ef3998d9f0b2f72a8d99e54
  installed to C:\Users\RUNNER~1\AppData\Local\Temp\xmake-cb1b65054db2a2917ef3998d9f0b2f72a8d99e54
C:\hostedtoolcache\windows\xmake\2.8.9\x64\xmake.exe --root --version
xmake v2.8.9+HEAD.cb1b65054, A cross-platform build utility based on Lua
Copyright (C) 2015-present Ruki Wang, tboox.org, xmake.io
                         _
    __  ___ __  __  __ _| | ______
    \ \/ / |  \/  |/ _  | |/ / __ \
     >  <  | \__/ | /_| |   <  ___/
    /_/\_\_|_|  |_|\__ \|_|\_\____|

                         by ruki, xmake.io
    
    👉  Manual: https://xmake.io/#/getting_started
    🙏  Donate: https://xmake.io/#/sponsor

Run 240506-fix-xmake branch on CI will produce the error listed above.

@waruqi
Copy link
Member

waruqi commented May 9, 2024

The main branch of LunaSDK is locked to Xmake v2.8.9 to prevent CI failure. It can be seen here:

I switched to dev and latest 2.9.1 version, it still works.

waruqi/LunaSDK@0d21b8c

https://github.com/waruqi/LunaSDK/actions/runs/9011763323

@JX-Master
Copy link
Author

I have confirmed that this issue will be affected by CI caching configuration. That says, if the xmake is configured using existing cache in Retrieve cached xmake dependencies step, they this error won't occur. But if the cache is not found, then this problem will occur. This make a very strange behavior: every action will fail on its first run, but if we re-run failed jobs, they will success because now the cache is present for the job.

To make this problem occur every time, caching in ci-windows-main.yml must be disabled like so:

JX-Master/LunaSDK@0218180

Then this problem should occur every time.

waruqi added a commit that referenced this issue May 9, 2024
@waruqi
Copy link
Member

waruqi commented May 9, 2024

this patch should work. #5076

@waruqi waruqi added this to the v2.9.2 milestone May 9, 2024
waruqi added a commit that referenced this issue May 9, 2024
@waruqi
Copy link
Member

waruqi commented May 9, 2024

you can try dev branch on ci. branch@dev.

@JX-Master
Copy link
Author

Confimed fixed on branch@dev. Thanks.

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

No branches or pull requests

2 participants