Skip to content

C++20 modules: vulkan-headers 开启 modules=true 时编译报 missing vulkan:video dependency #7572

@Souvenal

Description

@Souvenal

问题描述

C++ 添加vulkan-headers 包时若启用 C++ module,会编译报错:

error: <vulkan-headers> missing vulkan:video dependency for module vulkan

环境:

  • xmake v3.0.9+20260519
  • macOS Tahoe 26.5 arm64
  • Homebrew clang version 22.1.6 (LLVM 从 homebrew 安装)

复现步骤

set_project("foo")

add_requires("vulkan-headers", {configs={modules=true}})

target("foo")
    set_kind("binary")
    add_packages("vulkan-headers")
xmake f -p macosx -a arm64 --toolchain=clang -y -vD

实际输出

checking for clang ... /opt/homebrew/opt/llvm/bin/clang
checking for llvm resource dir ... /opt/homebrew/Cellar/llvm/22.1.6/lib/clang/22
checking for llvm target triple ... arm64-apple-darwin25.5.0
checking for git ... /usr/bin/git
checking for gzip ... /usr/bin/gzip
checking for tar ... /usr/bin/tar
/usr/bin/git rev-parse HEAD
finding vulkan-headers from xmake ..
checking for xmake::vulkan-headers ... no
finding vulkan-headers from brew ..
checking for brew ... /opt/homebrew/bin/brew
finding vulkan-headers from vcpkg ..
checking for vcpkg ... /Users/mac/SDKs/vcpkg/vcpkg
finding vulkan-headers from conan ..
finding vulkan-headers from pkgconfig ..
checking for pkg-config ... /opt/homebrew/bin/pkg-config
finding vulkan-headers from system ..
checking for clang ... /opt/homebrew/opt/llvm/bin/clang
checking for the c compiler (cc) ... clang
checking for /opt/homebrew/opt/llvm/bin/clang ... ok
checking for flags (-fPIC) ... ok
> clang "-fPIC" "-Qunused-arguments"
> /opt/homebrew/opt/llvm/bin/clang -c -Qunused-arguments -o /var/folders/zv/9qpm16ws1qzb0f34pk97c3vw0000gn/T/.xmake501/260529/_27b202d78aa19a0d8457a63717c7c996.o /var/folders/zv/9qpm16ws1qzb0f34pk97c3vw0000gn/T/.xmake501/260529/_5c2289377258fd5de3785c74a50568f0.c
checking for flags (-fdiagnostics-color=always) ... ok
> clang "-fdiagnostics-color=always" "-Qunused-arguments"
checking for flags (-Wno-gnu-line-marker -Werror) ... ok
> clang "-Wno-gnu-line-marker" "-Werror" "-Qunused-arguments"
checking for clang++ ... /opt/homebrew/opt/llvm/bin/clang++
checking for the linker (ld) ... clang++
checking for /opt/homebrew/opt/llvm/bin/clang++ ... ok
checking for flags (-fPIC) ... ok
> clang++ "-fPIC"
> /opt/homebrew/opt/llvm/bin/clang++ -o /var/folders/zv/9qpm16ws1qzb0f34pk97c3vw0000gn/T/.xmake501/260529/_27b202d78aa19a0d8457a63717c7c996.b /var/folders/zv/9qpm16ws1qzb0f34pk97c3vw0000gn/T/.xmake501/260529/_27b202d78aa19a0d8457a63717c7c996.o -lvulkan-headers
ld: library 'vulkan-headers' not found
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
> checking for c links(vulkan-headers)
> checking for c snippet(find_package/vulkan-headers)
checkinfo: ...gramdir/core/sandbox/modules/import/core/tool/linker.lua:75: @programdir/core/sandbox/modules/os.lua:378: execv(/opt/homebrew/opt/llvm/bin/clang++ -o /var/folders/zv/9qpm16ws1qzb0f34pk97c3vw0000gn/T/.xmake501/260529/_27b202d78aa19a0d8457a63717c7c996.b /var/folders/zv/9qpm16ws1qzb0f34pk97c3vw0000gn/T/.xmake501/260529/_27b202d78aa19a0d8457a63717c7c996.o -lvulkan-headers) failed(1), unknown reason
stack traceback:
    [C]: in function 'error'
    [@programdir/core/base/os.lua:1193]:
    [@programdir/core/sandbox/modules/os.lua:378]: in function 'execv'
    [@programdir/modules/core/tools/gcc.lua:963]:
    [C]: in function 'xpcall'
    [@programdir/core/base/utils.lua:299]:
    [@programdir/core/tool/linker.lua:245]: in function 'link'
    [...gramdir/core/sandbox/modules/import/core/tool/linker.lua:73]: in function 'link'
    [@programdir/modules/lib/detect/check_cxsnippets.lua:255]:
    [C]: in function 'xpcall'
    [@programdir/core/base/utils.lua:299]: in function 'trycall'
    [@programdir/core/sandbox/modules/try.lua:117]: in function 'try'
    [@programdir/modules/lib/detect/check_cxsnippets.lua:243]:
    [@programdir/modules/package/manager/system/find_package.lua:73]:
    [@programdir/modules/package/manager/find_package.lua:86]: in function '_find_package_with_builtin_rule'
    [@programdir/modules/package/manager/find_package.lua:132]: in function '_find_package'
    [@programdir/modules/package/manager/find_package.lua:208]:
    [@programdir/modules/lib/detect/find_package.lua:92]:
    [@programdir/core/package/package.lua:1950]: in function '_fetch_library'
    [@programdir/core/package/package.lua:2123]: in function 'fetch'
    [...modules/private/action/require/impl/install_packages.lua:354]: in function 'job_func'
    [@programdir/modules/async/runjobs.lua:462]:
    [C]: in function 'xpcall'
    [@programdir/core/base/utils.lua:299]: in function 'trycall'
    [@programdir/core/sandbox/modules/try.lua:117]: in function 'try'
    [@programdir/modules/async/runjobs.lua:431]: in function 'cotask'
    [@programdir/core/base/scheduler.lua:531]:

checking for vulkan-headers ... no
checking for curl ... /usr/bin/curl
pinging the host(github.com) ... 123 ms
/usr/bin/tar -xf /Users/mac/.cache/xmake/cache/2605/v/vulkan-headers/1.4.335+0/vulkan-headers-1.4.335+0.tar.gz -C source.tmp
/opt/homebrew/bin/xmake f --diagnosis --verbose --yes -y -c --plat=macosx --arch=arm64 --mode=release --kind=static --toolchain=clang --cxflags=-fPIC --builddir=build_bf8275dd
checking for clang ... /opt/homebrew/opt/llvm/bin/clang
checking for llvm resource dir ... /opt/homebrew/Cellar/llvm/22.1.6/lib/clang/22
checking for llvm target triple ... arm64-apple-darwin25.5.0
checking for clang++ ... /opt/homebrew/opt/llvm/bin/clang++
checking for the c++ compiler (cxx) ... clang++
checking for /opt/homebrew/opt/llvm/bin/clang++ ... ok
checking for flags (-fPIC) ... ok
> clang++ "-fPIC" "-Qunused-arguments"
checking for flags (clang_modules) ... ok
> clang++ "-fmodules" "-Qunused-arguments"
checking for flags (clang_modules_ts) ... no
> clang++ "-fmodules-ts" "-Qunused-arguments"
checkinfo: @programdir/core/sandbox/modules/os.lua:273: clang++: error: unknown argument: '-fmodules-ts'

stack traceback:
    [C]: in function 'error'
    [@programdir/core/base/os.lua:1193]:
    [@programdir/core/sandbox/modules/os.lua:273]: in function 'runv'
    [@programdir/modules/core/tools/gcc/has_flags.lua:45]:
checking for /opt/homebrew/opt/llvm/bin/clang++ ... ok
checking for flags (clang_print_library_module_manifest_path) ... ok
> clang++ "-print-library-module-manifest-path" "-Qunused-arguments"
configure
{
    proxy_pac = pac.lua
    plat = macosx
    host = macosx
    ccache = true
    arch = arm64
    builddir = build_bf8275dd
    network = public
    theme = default
    kind = static
    cxflags = -fPIC
    clean = true
    mode = release
    toolchain = clang
    ndk_stdcxx = true
}
/opt/homebrew/bin/xmake build --diagnosis --verbose --yes
checking for flags (-std=c++20) ... ok
> clang++ "-std=c++20" "-Qunused-arguments"
[  0%]: <vulkan-headers> generating.module.deps /opt/homebrew/opt/llvm/share/libc++/v1/std.compat.cppm
checking for /opt/homebrew/opt/llvm/bin/clang-scan-deps ... ok
/opt/homebrew/opt/llvm/bin/clang-scan-deps --format=p1689 -- /opt/homebrew/opt/llvm/bin/clang++ -x c++ -Qunused-arguments -std=c++20 -Iinclude -fPIC -c /opt/homebrew/opt/llvm/share/libc++/v1/std.compat.cppm -o build_bf8275dd/.objs/vulkan-headers/macosx/arm64/release/opt/homebrew/opt/llvm/share/libc++/v1/std.compat.cppm.o
[  0%]: <vulkan-headers> generating.module.deps /opt/homebrew/opt/llvm/share/libc++/v1/std.cppm
/opt/homebrew/opt/llvm/bin/clang-scan-deps --format=p1689 -- /opt/homebrew/opt/llvm/bin/clang++ -x c++ -Qunused-arguments -std=c++20 -Iinclude -fPIC -c /opt/homebrew/opt/llvm/share/libc++/v1/std.cppm -o build_bf8275dd/.objs/vulkan-headers/macosx/arm64/release/opt/homebrew/opt/llvm/share/libc++/v1/std.cppm.o
[  0%]: <vulkan-headers> generating.module.deps include/vulkan/vulkan.cppm
/opt/homebrew/opt/llvm/bin/clang-scan-deps --format=p1689 -- /opt/homebrew/opt/llvm/bin/clang++ -x c++ -Qunused-arguments -std=c++20 -Iinclude -fPIC -c include/vulkan/vulkan.cppm -o build_bf8275dd/.objs/vulkan-headers/macosx/arm64/release/include/vulkan/vulkan.cppm.o
[  0%]: <vulkan-headers> generating.module.deps include/vulkan/vulkan_video.cppm
/opt/homebrew/opt/llvm/bin/clang-scan-deps --format=p1689 -- /opt/homebrew/opt/llvm/bin/clang++ -x c++ -Qunused-arguments -std=c++20 -Iinclude -fPIC -c include/vulkan/vulkan_video.cppm -o build_bf8275dd/.objs/vulkan-headers/macosx/arm64/release/include/vulkan/vulkan_video.cppm.o
parsing: vulkan-headers 
modules: { 
  "/opt/homebrew/opt/llvm/share/libc++/v1/std.cppm" = { 
    objectfile = "build_bf8275dd/.objs/vulkan-headers/macosx/arm64/release/opt/homebrew/opt/llvm/share/libc++/v1/std.cppm.o",
    method = "by-name",
    name = "std",
    sourcefile = "/opt/homebrew/opt/llvm/share/libc++/v1/std.cppm",
    bmifile = "build_bf8275dd/.gens/vulkan-headers/macosx/arm64/release/rules/bmi/cache/interfaces/4301b8484b726443/std.pcm",
    interface = true 
  },
  "/opt/homebrew/opt/llvm/share/libc++/v1/std.compat.cppm" = { 
    objectfile = "build_bf8275dd/.objs/vulkan-headers/macosx/arm64/release/opt/homebrew/opt/llvm/share/libc++/v1/std.compat.cppm.o",
    method = "by-name",
    name = "std.compat",
    sourcefile = "/opt/homebrew/opt/llvm/share/libc++/v1/std.compat.cppm",
    bmifile = "build_bf8275dd/.gens/vulkan-headers/macosx/arm64/release/rules/bmi/cache/interfaces/ca1787d63af8bcbf/std.compat.pcm",
    deps = { 
      std = { 
        method = "by-name",
        name = "std",
        headerunit = false,
        unique = false,
        key = false 
      } 
    },
    interface = true 
  },
  "include/vulkan/vulkan_video.cppm" = { 
    objectfile = "build_bf8275dd/.objs/vulkan-headers/macosx/arm64/release/include/vulkan/vulkan_video.cppm.o",
    method = "by-name",
    name = "vulkan_hpp:video",
    sourcefile = "include/vulkan/vulkan_video.cppm",
    bmifile = "build_bf8275dd/.gens/vulkan-headers/macosx/arm64/release/rules/bmi/cache/interfaces/0c279175914fae5b/vulkan_hpp_PARTITION_video.pcm",
    deps = { 
      std = { 
        method = "by-name",
        name = "std",
        headerunit = false,
        unique = false,
        key = false 
      } 
    },
    interface = true 
  },
  "include/vulkan/vulkan.cppm" = { 
    objectfile = "build_bf8275dd/.objs/vulkan-headers/macosx/arm64/release/include/vulkan/vulkan.cppm.o",
    method = "by-name",
    name = "vulkan",
    sourcefile = "include/vulkan/vulkan.cppm",
    bmifile = "build_bf8275dd/.gens/vulkan-headers/macosx/arm64/release/rules/bmi/cache/interfaces/02832e243eb4353e/vulkan.pcm",
    deps = { 
      "vulkan:video" = { 
        method = "by-name",
        name = "vulkan:video",
        headerunit = false,
        unique = false,
        key = false 
      },
      std = { 
        method = "by-name",
        name = "std",
        headerunit = false,
        unique = false,
        key = false 
      } 
    },
    interface = true 
  } 
}

error: @programdir/core/main.lua:274: @programdir/actions/build/main.lua:162: @programdir/modules/async/runjobs.lua:282: @programdir/rules/c++/modules/scanner.lua:454: <vulkan-headers> missing vulkan:video dependency for module vulkan
stack traceback:
    [C]: in function 'error'
    [@programdir/core/base/os.lua:1193]:
    [@programdir/rules/c++/modules/scanner.lua:454]: in function '_do_computedag'
    [@programdir/rules/c++/modules/scanner.lua:595]: in function 'job_func'
    [@programdir/modules/async/runjobs.lua:462]:

stack traceback:
        [C]: in global 'error'
        @programdir/core/base/os.lua:1193: in function 'os.raiselevel'
        (...tail calls...)
        @programdir/core/main.lua:274: in upvalue 'cotask'
        @programdir/core/base/scheduler.lua:531: in function <@programdir/core/base/scheduler.lua:524>
error: @programdir/core/sandbox/modules/os.lua:378: execv(/opt/homebrew/bin/xmake build --diagnosis --verbose --yes) failed(255), unknown reason
stack traceback:
    [C]: in function 'error'
    [@programdir/core/base/os.lua:1193]:
    [@programdir/core/sandbox/modules/os.lua:378]:
    [@programdir/core/sandbox/modules/os.lua:291]: in function 'vrunv'
    [@programdir/modules/package/tools/xmake.lua:578]: in function 'install'
    [...ositories/xmake-repo/packages/v/vulkan-headers/xmake.lua:69]: in function 'script'
    [...dir/modules/private/action/require/impl/utils/filter.lua:114]: in function 'call'
    [.../modules/private/action/require/impl/actions/install.lua:484]:

  => install vulkan-headers 1.4.335+0 .. failed
error: @programdir/core/main.lua:274: @programdir/modules/async/runjobs.lua:282: .../modules/private/action/require/impl/actions/install.lua:596: install failed!
stack traceback:
    [C]: in function 'error'
    [@programdir/core/base/os.lua:1193]:
    [.../modules/private/action/require/impl/actions/install.lua:596]: in function 'catch'
    [@programdir/core/sandbox/modules/try.lua:123]: in function 'try'
    [.../modules/private/action/require/impl/actions/install.lua:451]:
    [...modules/private/action/require/impl/install_packages.lua:514]: in function 'job_func'
    [@programdir/modules/async/runjobs.lua:462]:

stack traceback:
        [C]: in global 'error'
        @programdir/core/base/os.lua:1193: in function 'base/os.raiselevel'
        (...tail calls...)
        @programdir/core/main.lua:274: in upvalue 'cotask'
        @programdir/core/base/scheduler.lua:531: in function <@programdir/core/base/scheduler.lua:524>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions