-
-
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
使用clang-cl并开启asan时,cxxflags里缺少-fsanitize=address,并且clang-cl不会主动链接clang_rt.asan-x86_64 #5728
Comments
Title: When using clang-cl and turning on asan, -fsanitize=address is missing in cxxflags, and clang-cl will not actively link clang_rt.asan-x86_64 Xmake versionv2.9.5 Operating system version and architectureWindows 10 22H2 Describe the problemWhen using clang-cl and turning on asan, -fsanitize=address is missing in cxxflags, and clang-cl will not actively link clang_rt.asan-x86_64 After testing, the Expected resultsCorrectly handle cxxflags and add links Project configurationtarget("play_ground")
set_kind("binary")
set_rundir("$(projectdir)")
set_policy("build.sanitizer.address", true)
add_languages("c++23")
add_files("src/*.cpp")
add_includedirs("src")
add_cxxflags("-std=c++23")
-- add_linkdirs("D:\\scoop\\apps\\llvm\\19.1.2\\lib\\clang\\19\\lib\\windows")
-- add_links("clang_rt.asan_dynamic-x86_64", "clang_rt.asan_dynamic_runtime_thunk-x86_64")
-- add_links("clang_rt.asan-x86_64")
add_packages(requirements)
set_toolchains("clang-cl")
-- set_toolset("ld", "lld-link")
target_end() Additional information and error logschecking for flags (-DNDEBUG) ... ok
[60%]: cache compiling.release src\main.cpp
D:\scoop\apps\llvm\current\bin\clang-cl.exe -c -m64 -Zi -FS -Fdbuild\windows\x64\release\compile.play_ground.pdb -O2 -std:c++20 - std:c++latest -MD -Isrc /EHsc /utf-8 -Xclang -std=c++23 -DNDEBUG -Fobuild\.objs\play_ground\windows\x64\release\src\main.cpp.obj src\ main.cpp
checking for flags (-fcolor-diagnostics) ... ok
checking for flags (-fansi-escape-codes) ... ok
[60%]: cache compiling.release src\thread_pool.cpp
D:\scoop\apps\llvm\current\bin\clang-cl.exe -c -m64 -Zi -FS -Fdbuild\windows\x64\release\compile.play_ground.pdb -O2 -std:c++20 - std:c++latest -MD -Isrc /EHsc /utf-8 -Xclang -std=c++23 -DNDEBUG -Fobuild\.objs\play_ground\windows\x64\release\src\thread_pool.cpp.obj src\ thread_pool.cpp
[80%]: linking.release play_ground.exe
"D:\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.41.34120\\bin\\HostX64\\x64\\link.exe" -nologo -dynamicbase -nxcompat - machine:x64 /opt:ref /opt:icf -debug -pdb:build\windows\x64\release\play_ground.pdb -out:build\windows\x64\release\play_ground.exe build\.objs\play_ground\windows\ x64\release\src\main.cpp.obj build\.objs\play_ground\windows\x64\release\src\thread_pool.cpp.obj
checking for clang-cl.exe ... D:\scoop\apps\llvm\current\bin\clang-cl.exe
checking for the c compiler (cc) ... clang-cl.exe
checking for flags (cl_external_includedir) ... ok
Create OK!
compile_commands.json updated!
[100%]: build ok, spent 1.563s |
clang 相关的 toolchain 大概都需要处理 |
clang 原本就支持,clang-cl 还没处理,只支持了 cl 。。可以提个 pr 过来
|
clang originally supported it, clang-cl has not been processed yet, and only cl is supported. . Can you submit a PR?
|
试下这个 patch #5742
这边测试没这个问题,而且 clang-cl 是编译器 又不是链接器 PS C:\Users\wangrunqing\Downloads\test91> xmake f --toolchain=clang-cl -c
checking for platform ... windows
checking for architecture ... x64
checking for Microsoft Visual Studio (x64) version ... 2022
checking for LLVM Clang C/C++ Compiler (x64) version ... 18.1.6
PS C:\Users\wangrunqing\Downloads\test91> xmake -rv
checking for C:\Program Files\LLVM\bin\clang-cl.exe ... ok
checking for flags (-FS -Fd) ... ok
checking for flags (-O2) ... ok
checking for flags (-DNDEBUG) ... ok
[ 50%]: cache compiling.release src\main.cpp
"C:\\Program Files\\LLVM\\bin\\clang-cl.exe" -c -m64 -Zi -FS -Fdbuild\windows\x64\release\compile.toytrain.pdb -O2 -std:c++latest /EHsc -fsanitize=address -DNDEBUG -Fobuild\.objs\toytrain\windows\x64\release\src\main.cpp.obj src\main.cpp
checking for flags (-fcolor-diagnostics) ... ok
checking for flags (-fansi-escape-codes) ... ok
[ 75%]: linking.release toytrain.exe
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Preview\\VC\\Tools\\MSVC\\14.41.33923\\bin\\HostX64\\x64\\link.exe" -nologo -dynamicbase -nxcompat -machine:x64 /opt:ref /opt:icf -debug -pdb:build\windows\x64\release\toytrain.pdb -fsanitize=address -out:build\windows\x64\release\toytrain.exe build\.objs\toytrain\windows\x64\release\src\main.cpp.obj
checking for clang-cl.exe ... C:\Program Files\LLVM\bin\clang-cl.exe
checking for the c compiler (cc) ... clang-cl.exe
[100%]: build ok, spent 2.547s
PS C:\Users\wangrunqing\Downloads\test91> xmake r
hello world! |
没问题了,感谢! |
Xmake 版本
v2.9.5
操作系统版本和架构
Windows10 22H2
描述问题
使用clang-cl并开启asan时,cxxflags里缺少-fsanitize=address,并且clang-cl不会主动链接clang_rt.asan-x86_64
经过测试,llvm自带的
clang_rt.asan-x86_64
路径:\path\to\llvm\version\lib\clang\19\lib\windows
并不在系统路径中, 直接add_links("clang_rt.asan-x86_64")
并不奏效, 并且只链接clang_rt.asan-x86_64, asan功能不完善.期待的结果
正确处理cxxflags, 并且添加链接
工程配置
附加信息和错误日志
The text was updated successfully, but these errors were encountered: