-
-
Notifications
You must be signed in to change notification settings - Fork 818
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
目标平台为 Windows 时 Clang 工具链不主动加载 MSVC 编译环境 #5978
Comments
Title: When the target platform is Windows, the Clang tool chain does not actively load the MSVC compilation environment |
UpdateClang 在目标平台为 Windows 时,是会加载 MSVC 环境变量的,只是不知道为什么,似乎不太管用 xmake/xmake/toolchains/clang/load.lua Lines 67 to 85 in bd09a63
|
UpdateClang will load the MSVC environment variable when the target platform is Windows, but I don’t know why and it doesn’t seem to work. xmake/xmake/toolchains/clang/load.lua Lines 67 to 85 in bd09a63
|
可以 |
You can |
xmake f -c -vD --toolchain=clang
xmake -r -vD hello_c
|
在这段代码后面用 可能是 check 时没添加到 xmake/xmake/toolchains/clang/check.lua Lines 58 to 69 in a2ee23e
|
Use It may be that it was not added during check. xmake/xmake/toolchains/clang/check.lua Lines 58 to 69 in a2ee23e
I did not specify sdk, and |
或许可以模仿 clang-cl 工具链的做法,寻找 vs 并添加相关环境变量 xmake/xmake/toolchains/clang-cl/check.lua Lines 140 to 171 in 70eb7bb
我将上面这段复制给 clang 的 check: xmake/xmake/toolchains/clang/check.lua Lines 58 to 69 in a2ee23e
可以编译本地项目 |
Specifying xmake/xmake/toolchains/clang/check.lua Lines 25 to 31 in a2ee23e
The possible reason is that the installation path of xmake/xmake/modules/detect/sdks/find_vstudio.lua Lines 102 to 139 in a2ee23e
On my computer, |
目前 clang 那个 toolchain ,check 阶段仅仅做了 portable build msvc 的支持,不会去检测加载系统 vs 环境。 只有 clang-cl 的才会。 xmake/xmake/toolchains/clang-cl/check.lua Line 168 in 323eb11
另外,即使 clang toolchain 不加载 msvc ,也是可以正常编译的。 xmake f --toolchain=clang -c; xmake -rv
checking for platform ... windows
checking for architecture ... x64
checking for clang ... ok
checking for the c compiler (cc) ... clang
checking for flags (-O3) ... ok
checking for flags (-DNDEBUG) ... ok
checking for clang ... ok
checking for the c++ compiler (cxx) ... clang
[ 50%]: cache compiling.release src\main.c
clang -c -Qunused-arguments -m64 --target=x86_64-windows-msvc -fvisibility=hidden -O3 -DNDEBUG -o build\.objs\test\windows\x64\release\src\main.c.obj src\main.c
checking for flags (-MMD -MF) ... ok
checking for flags (-fdiagnostics-color=always) ... ok
checking for flags (-fansi-escape-codes) ... ok
checking for flags (-Wno-gnu-line-marker -Werror) ... ok
[ 75%]: linking.release test.exe
clang++ -o build\windows\x64\release\test.exe build\.objs\test\windows\x64\release\src\main.c.obj -m64 --target=x86_64-windows-msvc
[100%]: build ok, spent 1.766s 而且 llvm/clang 原本就不应该跟 msvc 两套环境强耦合绑定。它本就是独立的工具链,有自己的 libc++ 头文件,干嘛默认要跟 msvc 耦合在一起?除非显式指定 要用 msvc 的 |
对哦,我一时没转过弯来,想得不够周到 |
That's right, I didn't turn around for a moment and didn't think carefully enough. |
Xmake 版本
xmake v2.9.6+HEAD.abd15c255
操作系统版本和架构
Windows 10
描述问题
使用 Clang 工具链(LLVM-MinGW)为 Windows 平台构建程序,出现找不到标准库头文件的错误
而在
Developer PowerShell
中执行clang -m64 --target=x86_64-windows-msvc src\hello.c
可以正常编译期待的结果
使用 Clang 工具链时,能主动加载 MSVC 环境(类似使用 MSVC 工具链时 XMake 的行为)
工程配置
附加信息和错误日志
诊断日志
The text was updated successfully, but these errors were encountered: