Skip to content

工具链检测有问题 #6152

@heheda123123

Description

@heheda123123

Xmake 版本

v2.9.8+dev.5ac4306ee

操作系统版本和架构

windows 11

描述问题

随便新建一个项目,用如下的工程配置

toolchain("myclang")
    -- set_kind("standalone")
    set_toolset("cc",      "clang")
    set_toolset("cxx",     "clang",   "clang++")
    set_toolset("ld",      "clang++", "clang")
    set_toolset("sh",      "clang++", "clang")
    set_toolset("as",      "clang")
    set_toolset("ar",      "llvm-ar")
    set_toolset("strip",   "llvm-strip")
    set_toolset("ranlib",  "llvm-ranlib")
    set_toolset("objcopy", "llvm-objcopy")
    set_toolset("mrc",     "llvm-rc")
    -- on_check(function(toolchain)
    --     return import("lib.detect.find_program")("clang")
    -- end)
toolchain_end()

target("testzigz")
    set_kind("binary")
    add_files("src/*.cpp")

执行如下的命令

PS C:\Users\Administrator\temp\testzigz> xmake f -c --toolchain=myclang -v -D --sdk=C:\me\tools\Win64-MT-19.1.3-obf1.6.0
checking for platform ... windows
checking for architecture ... x64
checkinfo: cannot runv(clang.exe --version), No such file or directory
checking for clang ... no
checking for zig ... ok
checking for nim ... ok
checking for clang++ ... C:\me\tools\Win64-MT-19.1.3-obf1.6.0\bin\clang++
checking for the linker (ld) ... clang++
checking for clang++ ... C:\me\tools\Win64-MT-19.1.3-obf1.6.0\bin\clang++
checking for the shared library linker (sh) ... clang++
configure
{
    network = public
    ndk_stdcxx = true
    ccache = true
    host = windows
    proxy = socks5://127.0.0.1:7890
    proxy_pac = pac.lua
    mode = release
    arch = x64
    sdk = C:\me\tools\Win64-MT-19.1.3-obf1.6.0
    kind = static
    theme = default
    toolchain = myclang
    plat = windows
    clean = true
    buildir = build
}

可以看到clang++找到了,但是clang没有找到(程序确实是存在的)(话说开启debug的时候,遇到not found的错误,能不能把完整路径也输出出来,不然光是输出个程序名,也不知道为啥)

如果修改工程配置,启用find_program会发现没有按照set_toolset的工具名来,把zigcc\c++.cmd识别出来作为编译工具了

toolchain("myclang")
    -- set_kind("standalone")
    set_toolset("cc",      "clang")
    set_toolset("cxx",     "clang",   "clang++")
    set_toolset("ld",      "clang++", "clang")
    set_toolset("sh",      "clang++", "clang")
    set_toolset("as",      "clang")
    set_toolset("ar",      "llvm-ar")
    set_toolset("strip",   "llvm-strip")
    set_toolset("ranlib",  "llvm-ranlib")
    set_toolset("objcopy", "llvm-objcopy")
    set_toolset("mrc",     "llvm-rc")
    on_check(function(toolchain)
        return import("lib.detect.find_program")("clang")
    end)
toolchain_end()

target("testzigz")
    set_kind("binary")
    add_files("src/*.cpp")
PS C:\Users\Administrator\temp\testzigz> xmake f -c --toolchain=myclang -v -D --sdk=C:\me\tools\Win64-MT-19.1.3-obf1.6.0
checking for platform ... windows
checking for architecture ... x64
checkinfo: cannot runv(clang.exe --version), No such file or directory
checking for clang ... no
checking for zig ... ok
checking for nim ... ok
checking for Cuda SDK directory ... no
checkinfo: cannot runv(nvc++.exe --version), No such file or directory
checking for nvc++ ... no
checking for the linker (ld: nvc++) ... no
checking for Cuda SDK directory ... no
checkinfo: cannot runv(nvc.exe --version), No such file or directory
checking for nvc ... no
checking for the linker (ld: nvc) ... no
checking for C:\Users\ADMINI~1\AppData\Local\Temp\.xmake\250213\zigcc\c++.cmd ... ok
checking for the linker (ld) ... c++.cmd
checking for Cuda SDK directory ... no
checkinfo: cannot runv(nvc++.exe --version), No such file or directory
checking for nvc++ ... no
checking for the shared library linker (sh: nvc++) ... no
checking for Cuda SDK directory ... no
checkinfo: cannot runv(nvc.exe --version), No such file or directory
checking for nvc ... no
checking for the shared library linker (sh: nvc) ... no
checking for C:\Users\ADMINI~1\AppData\Local\Temp\.xmake\250213\zigcc\c++.cmd ... ok
checking for the shared library linker (sh) ... c++.cmd
configure
{
    clean = true
    theme = default
    network = public
    kind = static
    plat = windows
    host = windows
    proxy = socks5://127.0.0.1:7890
    ndk_stdcxx = true
    ccache = true
    arch = x64
    toolchain = myclang
    buildir = build
    proxy_pac = pac.lua
    sdk = C:\me\tools\Win64-MT-19.1.3-obf1.6.0
    mode = release
}
PS C:\Users\Administrator\temp\testzigz>

期待的结果

1 能正确按照工具链设置的程序名来
2 正确识别通过--sdk传入的工具链

工程配置

已提供

附加信息和错误日志

已提供

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions