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

Cross compile bug #5658

Closed
MaxwellGengYF opened this issue Sep 24, 2024 · 3 comments
Closed

Cross compile bug #5658

MaxwellGengYF opened this issue Sep 24, 2024 · 3 comments
Labels
Milestone

Comments

@MaxwellGengYF
Copy link
Contributor

Xmake 版本

v2.9.5+dev.21e4c2a3a

操作系统版本和架构

Windows

描述问题

同项目使用 cross compile 导致 can not find program ar

期待的结果

正常编译。

工程配置

target("llvm_target")
set_languages("cxx20")
set_toolchains("llvm")
on_load(function(target)
    target:set("kind", "static")
end)
add_files("dummy.cpp")
target_end()

target("clang_cl_target")
set_languages("cxx20")
on_load(function(target)
    target:set("kind", "static")
end)
add_files("dummy.cpp")
target_end()

xmake f -m debug --toolchain=clang_cl -c
xmake
xmake f -m release --toolchain=clang_cl -c
xmake
xmake f -m debug --toolchain=clang_cl -c
xmake
...

附加信息和错误日志

error: cannot get program for ar

waruqi added a commit that referenced this issue Sep 25, 2024
@waruqi waruqi added this to the v2.9.6 milestone Sep 25, 2024
@waruqi
Copy link
Member

waruqi commented Sep 25, 2024

试下,应该可以了,这个跟 cache 没啥关系,是 clang-cl toolchain 的问题。。

因为 msvc/clang-cl 都是用的 link.exe ,但是探测 find_link 需要调用 cl/clang-cl 去尝试编译+ link

切到 clang-cl toolchain 后,envs 被加载为 clang-cl的环境,cl.exe 不在 PATH 里,所以之前 find_link 固定用 cl.exe 去探测,就会出这个问题,导致 link.exe 没找到。

@waruqi
Copy link
Member

waruqi commented Sep 25, 2024

#5661

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Try it, it should work. This has nothing to do with the cache, it is a problem with the clang-cl toolchain. .

Because msvc/clang-cl all use link.exe, but to detect find_link you need to call cl/clang-cl to try to compile + link

After switching to the clang-cl toolchain, envs is loaded as the clang-cl environment, and cl.exe is not in the PATH. Therefore, before find_link was fixed to use cl.exe to detect, this problem will occur, causing link.exe not to be found.

waruqi added a commit that referenced this issue Sep 25, 2024
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

3 participants