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

clang-scan-deps中应该使用绝对路径 #4575

Closed
24bit-xjkp opened this issue Jan 6, 2024 · 8 comments
Closed

clang-scan-deps中应该使用绝对路径 #4575

24bit-xjkp opened this issue Jan 6, 2024 · 8 comments
Labels
Milestone

Comments

@24bit-xjkp
Copy link
Contributor

Xmake 版本

2.8.5

操作系统版本和架构

Windows 11 23H2

描述问题

[  0%]: generating.module.deps module.ixx
clang-scan-deps --format=p1689 -- clang -x c++ -c module.ixx -o build\.objs\test\windows\x64\release\module.ixx.obj -Qunused-arguments -m64 -std=c++23 -fexceptions -fcxx-exceptions
error: Error while scanning dependencies for module.ixx:
...
D:/Tools/gcc/include/malloc.h:83:10: fatal error: 'mm_malloc.h' file not found

而之所以clang找不到头文件是因为"clang-scan-deps --format=p1689 -- clang -x c++ -c module.ixx -o build.objs\test\windows\x64\release\module.ixx.obj -Qunused-arguments -m64 -std=c++23 -fexceptions -fcxx-exceptions"中的clang没有使用绝对路径,我在rules/c++/modules/modules_support/clang.lua里找到了问题所在

-- We need absolute path of clang to use clang-scan-deps
-- See https://clang.llvm.org/docs/StandardCPlusPlusModules.html#possible-issues-failed-to-find-system-headers
local clang_path = compinst:program()
if not path.is_absolute(clang_path) then
        clang_path = _get_clang_path(target) or compinst:program()
end

但事实上clang_path中仍然是"clang"而不是绝对路径

期待的结果

应该使用clang的绝对路径

工程配置

-- xmake.lua
set_languages("c++latest")
target("test")
    add_files("*.cpp", "*.ixx")
// module.ixx
module;
#include <iostream>
export module A;
// test.cpp
import A;
int main() {}

xmake的构建命令为xmake f --toolchain=clang; xmake build

附加信息和错误日志

[  0%]: generating.module.deps test.cpp
clang-scan-deps --format=p1689 -- clang -x c++ -c test.cpp -o build\.objs\test\windows\x64\release\test.cpp.obj -Qunused-arguments -m64 -std=c++23 -fexceptions -fcxx-exceptions
[  0%]: generating.module.deps module.ixx
clang-scan-deps --format=p1689 -- clang -x c++ -c module.ixx -o build\.objs\test\windows\x64\release\module.ixx.obj -Qunused-arguments -m64 -std=c++23 -fexceptions -fcxx-exceptions
error: Error while scanning dependencies for module.ixx:
In file included from module.ixx:2:
In file included from D:/Tools/gcc/include/c++/14.0.0/iostream:41:
In file included from D:/Tools/gcc/include/c++/14.0.0/ostream:40:
In file included from D:/Tools/gcc/include/c++/14.0.0/ios:44:
In file included from D:/Tools/gcc/include/c++/14.0.0/bits/ios_base.h:39:
In file included from D:/Tools/gcc/include/c++/14.0.0/ext/atomicity.h:35:
In file included from D:/Tools/gcc/include/c++/14.0.0/x86_64-w64-mingw32/bits/gthr.h:148:
In file included from D:/Tools/gcc/include/c++/14.0.0/x86_64-w64-mingw32/bits/gthr-default.h:32:
In file included from D:/Tools/gcc/include/c++/14.0.0/stdlib.h:36:
In file included from D:/Tools/gcc/include/c++/14.0.0/cstdlib:79:
In file included from D:/Tools/gcc/include/stdlib.h:769:
D:/Tools/gcc/include/malloc.h:83:10: fatal error: 'mm_malloc.h' file not found

stack traceback:
        [C]: in function 'error'
        @programdir\core\base\os.lua:927: in function 'base/os.raiselevel'
        (...tail calls...)
        @programdir\core\main.lua:309: in upvalue 'cotask'
        @programdir\core\base\scheduler.lua:404: in function <@programdir\core\base\scheduler.lua:397>
@24bit-xjkp 24bit-xjkp added the bug label Jan 6, 2024
@Issues-translate-bot
Copy link

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


Title: Absolute paths should be used in clang-scan-deps

@waruqi
Copy link
Member

waruqi commented Jan 6, 2024

再试试

xmake update -s dev

@Issues-translate-bot
Copy link

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


try again

xmake update -s github:xmake-io/xmake#clang

@24bit-xjkp
Copy link
Contributor Author

看起来不行,我在此处设置了print语句

if program and (toolname == "clang" or toolname == "clangxx") then
    local clang = find_tool("clang", {program = program, envs = os.getenvs()})
    print(clang)
    if clang then
        clang_path = clang.program
    end
end

但输出的结果是

{
  name = "clang",
  program = "clang"
}

依然只有clang而没有绝对路径

waruqi added a commit that referenced this issue Jan 8, 2024
@waruqi
Copy link
Member

waruqi commented Jan 8, 2024

再试试,xmake update -s dev

@waruqi waruqi added this to the v2.8.7 milestone Jan 8, 2024
@Issues-translate-bot
Copy link

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


Try again, xmake update -s dev

@24bit-xjkp
Copy link
Contributor Author

现在可以正常工作了

@Issues-translate-bot
Copy link

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


It works fine now

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