xmake icon indicating copy to clipboard operation
xmake copied to clipboard

开启asan时,包会自动使用debug版本

Open limibo777 opened this issue 1 year ago • 20 comments

Xmake 版本

2.9.6

操作系统版本和架构

Linux debian 6.1.0-28-amd64

描述问题

set_policy("build.sanitizer.address", true) add_requires("fmt =10.2.1", { system = false, debug=false, configs = { shared = true}}) add_requires("zeromq =4.3.4", { system = false, configs = { shared = true}})

target ("test") add_packages("fmt") add_packages("zeromq") set_kind("binary") add_files("test.cpp")

xmake f -m asan xmake -av 添加的so为debug版本

换成tsan的方式set_policy("build.sanitizer.thread", true)使用的则是release版本的so

工程配置

xmake.lua set_policy("build.sanitizer.address", true)

add_requires("fmt =10.2.1", { system = false, debug=false, configs = { shared = true}}) add_requires("zeromq =4.3.4", { system = false, configs = { shared = true}})

target ("test")

add_packages("fmt")
add_packages("zeromq")

set_kind("binary")
add_files("test.cpp")
set_targetdir("bin")
set_basename("test")

test.cpp #include <fmt/format.h> #include #include <assert.h> static void test() { std::string s = fmt::format("{}", "hello"); assert(s == "hello"); }

int main() { test(); return 0; }

附加信息和错误日志

/usr/bin/g++ -o bin/test build/.objs/test/linux/x86_64/asan/test.cpp.o -m64 -L/home/qwqe/.xmake/packages/f/fmt/10.2.1/3b4266b216a9438eb7a3de6ef0d67a72/lib -L/home/qwqe/.xmake/packages/z/zeromq/4.3.4/653b8975302f43ab9b0e57200b529ebb/lib -lfmtd -lzmq -lpthread -fsanitize=address

limibo777 avatar Feb 07 '25 07:02 limibo777

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


Title: When asan is enabled, the package fmt will automatically use the debug version

Issues-translate-bot avatar Feb 07 '25 07:02 Issues-translate-bot

是否 debug 只跟 debug = true 配置有关。

https://github.com/xmake-io/xmake-repo/blob/d7a0779921ae2ce42700398f1ecaa0995fca491b/packages/f/fmt/xmake.lua#L72

没有根据 asan 去设置 debug 的逻辑,除非 cmake 自己切了。你可以调下 包

waruqi avatar Feb 07 '25 08:02 waruqi

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


Whether debugging is only related to the debug = true configuration.

https://github.com/xmake-io/xmake-repo/blob/d7a0779921ae2ce42700398f1ecaa0995fca491b/packages/f/fmt/xmake.lua#L72

There is no logic to set debug based on asan, unless cmake cuts it by itself. You can adjust the package

Issues-translate-bot avatar Feb 07 '25 08:02 Issues-translate-bot

是否 debug 只跟 debug = true 配置有关。

https://github.com/xmake-io/xmake-repo/blob/d7a0779921ae2ce42700398f1ecaa0995fca491b/packages/f/fmt/xmake.lua#L72

没有根据 asan 去设置 debug 的逻辑,除非 cmake 自己切了。你可以调下 包

并不只是fmt的问题,貌似是开启asan会设置debug=true,对项目和packages都生效了,但是tsan只对项目生效了,对packages不生效

limibo777 avatar Feb 07 '25 08:02 limibo777

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


Whether debugging is only related to the debug = true configuration.

https://github.com/xmake-io/xmake-repo/blob/d7a0779921ae2ce42700398f1ecaa0995fca491b/packages/f/fmt/xmake.lua#L72

There is no logic to set debug based on asan, unless cmake cuts it by itself. You can adjust the package

It's not just a problem with fmt. It seems that if you enable asan, you will set debug=true, which will take effect on both the project and packages, but tsan only takes effect on the project and does not take effect on packages.

Issues-translate-bot avatar Feb 07 '25 08:02 Issues-translate-bot

并不只是fmt的问题,貌似是开启asan会设置debug=true,对项目和packages都生效了,但是tsan只对项目生效了,对packages不生效

那跟 debug 是两个问题,目前包仅仅支持 asan 不支持 tsan

waruqi avatar Feb 07 '25 09:02 waruqi

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


It's not just a problem with fmt. It seems that if you enable asan, you will set debug=true, which will take effect on both the project and packages, but tsan only takes effect on the project and does not take effect on packages.

That is two different problems with debug. Currently, the package only supports asan but not tsan.

Issues-translate-bot avatar Feb 07 '25 09:02 Issues-translate-bot

目前实现 https://github.com/xmake-io/xmake/blob/774980f0d1a660d3f33c97c2fe4d31fb5128f59e/xmake/core/package/package.lua#L698-L701

star-hengxing avatar Feb 07 '25 09:02 star-hengxing

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


Currently implemented https://github.com/xmake-io/xmake/blob/774980f0d1a660d3f33c97c2fe4d31fb5128f59e/xmake/core/package/package.lua#L698-L701

Issues-translate-bot avatar Feb 07 '25 09:02 Issues-translate-bot

哦,目前 asan 是默认 debug 的,因为要看栈,否则跑出来也看不到栈。除非单独加 -g ,tsan 目前包不支持,不会去处理

waruqi avatar Feb 07 '25 10:02 waruqi

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


Oh, currently asan is the default debug because you have to look at the stack, otherwise you won’t be able to see the stack even if you run out. Unless -g is added separately, the tsan package is not supported at present and will not be processed.

Issues-translate-bot avatar Feb 07 '25 10:02 Issues-translate-bot

哦,目前 asan 是默认 debug 的,因为要看栈,否则跑出来也看不到栈。除非单独加 -g ,tsan 目前包不支持,不会去处理

谢谢,我已经了解这个现象出现的原因。 还有两个问题想请教下 1.AddressSanitizer官方推荐的编译配置是 -O1 -fno-omit-frame-pointer 是能看到栈信息的,为何这里asan要强制debug 2.tsan也会强制debug,但是对应的包不会强制debug,这不合理,后续是否会增加tsan(同时msan,ubsan也是一样)对包的支持

limibo777 avatar Feb 10 '25 01:02 limibo777

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


Oh, currently asan is the default debug because you have to look at the stack, otherwise you won’t be able to see the stack even if you run out. Unless -g is added separately, the tsan package is not supported at present and will not be processed.

Thank you, I already understand the reason for this phenomenon. There are two more questions I would like to ask

  1. The official recommended compilation configuration of AddressSanitizer is -O1 -fno-omit-frame-pointer. You can see the stack information. Why does asan force debugging here? 2.tsan will also force debugging, but the corresponding package will not force debugging. This is unreasonable. Will tsan be added in the future (at the same time, msan and ubsan are the same) support for packages.

Issues-translate-bot avatar Feb 10 '25 02:02 Issues-translate-bot

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


Oh, currently asan is the default debug because you have to look at the stack, otherwise you won’t be able to see the stack even if you run out. Unless -g is added separately, the tsan package is not supported at present and will not be processed.

Thank you, I already understand the reason for this phenomenon. There are two more questions I would like to ask

  1. The official recommended compilation configuration of AddressSanitizer is -O1 -fno-omit-frame-pointer. You can see the stack information. Why does asan force debugging here? 2.tsan will also force debugging, but the corresponding package will not force debugging. This is unreasonable. Will tsan be added in the future (at the same time, msan and ubsan are the same) support for packages.

Issues-translate-bot avatar Feb 10 '25 02:02 Issues-translate-bot

哦,目前 asan 是默认 debug 的,因为要看栈,否则跑出来也看不到栈。除非单独加 -g ,tsan 目前包不支持,不会去处理

谢谢,我已经了解这个现象出现的原因。 还有两个问题想请教下 1.AddressSanitizer官方推荐的编译配置是 -O1 -fno-omit-frame-pointer 是能看到栈信息的,为何这里asan要强制debug 2.tsan也会强制debug,但是对应的包不会强制debug,这不合理,后续是否会增加tsan(同时msan,ubsan也是一样)对包的支持

-O1 -fno-omit-frame-pointer 是能看到栈信息的

这只是能取栈把,没加 -g 哪来的符号?怎么还原栈 定位到具体代码行号?

waruqi avatar Feb 10 '25 02:02 waruqi

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


Oh, currently asan is the default debug because you have to look at the stack, otherwise you won’t be able to see the stack even if you run out. Unless -g is added separately, the tsan package is not supported at present and will not be processed.

Thank you, I already understand the reason for this phenomenon. There are two more questions I would like to ask about 1. The official compilation configuration recommended by AddressSanitizer is -O1 -fno-omit-frame-pointer. You can see the stack information. Why does asan force debugging here? 2.tsan also force debugging, but The corresponding package will not force debugging, which is unreasonable. Will tsan be added in the future (at the same time, msan and ubsan are the same) support for packages

-O1 -fno-omit-frame-pointer can see stack information

This is just a stack handle, without adding -g where does the symbol come from? How to restore the stack and locate the specific code line number?

Issues-translate-bot avatar Feb 10 '25 02:02 Issues-translate-bot

哦,目前 asan 是默认 debug 的,因为要看栈,否则跑出来也看不到栈。除非单独加 -g ,tsan 目前包不支持,不会去处理

谢谢,我已经了解这个现象出现的原因。 还有两个问题想请教下 1.AddressSanitizer官方推荐的编译配置是 -O1 -fno-omit-frame-pointer 是能看到栈信息的,为何这里asan要强制debug 2.tsan也会强制debug,但是对应的包不会强制debug,这不合理,后续是否会增加tsan(同时msan,ubsan也是一样)对包的支持

-O1 -fno-omit-frame-pointer 是能看到栈信息的

这只是能取栈把,没加 -g 哪来的符号?怎么还原栈 定位到具体代码行号?

是的,需要加-g来定位具体代码行号,请问下tsan msan ubsan也都是按照debug方式编译的,但是引入的包还是用的release版本,后续会增加对包的支持吗

limibo777 avatar Feb 10 '25 05:02 limibo777

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


Oh, currently asan is the default debug because you have to look at the stack, otherwise you won’t see the stack even if you run out. Unless -g is added separately, the tsan package is not supported at present and will not be processed.

Thank you, I already understand the reason for this phenomenon. There are two more questions I would like to ask about 1. The official compilation configuration recommended by AddressSanitizer is -O1 -fno-omit-frame-pointer. You can see the stack information. Why does asan force debugging here? 2.tsan also force debugging, but The corresponding package will not force debugging, which is unreasonable. Will tsan be added in the future (at the same time, msan and ubsan are the same) support for packages

-O1 -fno-omit-frame-pointer can see stack information

This is just a stack handle, without adding -g where does the symbol come from? How to restore the stack and locate the specific code line number?

Yes, you need to add -g to locate the specific code line number. Can you ask if tsan msan ubsan is also compiled according to debug mode, but the packages introduced still use the release version. Will the package support be added in the future?

Issues-translate-bot avatar Feb 10 '25 05:02 Issues-translate-bot

这几个不太常用,目前不考虑,后面看情况。 可以自己直接传 cxflags ldflags 给 add_requires 来开启

waruqi avatar Feb 10 '25 15:02 waruqi

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


These are not commonly used, so I won’t consider it at the moment, and it depends on the situation later. You can directly pass cxflags ldflags to add_requires to start

Issues-translate-bot avatar Feb 10 '25 16:02 Issues-translate-bot