chen3feng / blade-build

Blade is a powerful build system from Tencent, supports many mainstream programming languages, such as C/C++, java, scala, python, protobuf...
Other
2.04k stars 501 forks source link

请问如何在blade中应用AddressSanitizer #578

Open kaocs opened 4 years ago

kaocs commented 4 years ago

如题

WindLeeWT commented 4 years ago

修改 BLADE_ROOT 如下

cc_config(
    cppflags = [
        # Other flags...
        '-fsanitize=address',        
    ],
    # Other configurations...
    linkflags = [
        # Other flags...
        '-fsanitize=address -static-libasan', 
    ]
)

此外,需要注意的是,使用 AddressSanitizer 时,不能链接其他的内存管理库,例如 tcmalloc/jemalloc

chen3feng commented 4 years ago

考虑支持命令行启用

paleyl commented 4 years ago

blade启动前,先执行下面命令,不知是否可行 export CPP="cpp -fsanitize=address" export CXX="c++ -fsanitize=address" export CC="gcc -fsanitize=address" export LD="c++ -fsanitize=address"

paleyl commented 4 years ago

修改 BLADE_ROOT 如下

cc_config(
    cppflags = [
        # Other flags...
        '-fsanitize=address',        
    ],
    # Other configurations...
    linkflags = [
        # Other flags...
        '-fsanitize=address -static-libasan', 
    ]
)

此外,需要注意的是,使用 AddressSanitizer 时,不能链接其他的内存管理库,例如 tcmalloc/jemalloc

请问这个'-fsanitize=address -static-libasan', 对gcc的版本有要求吗? Linking Shared Library build64_release/app/brand/common/libdatetime.so g++: error: unrecognized command line option '-fsanitize=address -static-libasan'

chen3feng commented 4 years ago

分开写呢?分别用引号包括,逗号分割

On Tue, Jun 30, 2020, 17:28 paleyl notifications@github.com wrote:

修改 BLADE_ROOT 如下

cc_config(

cppflags = [

    # Other flags...

    '-fsanitize=address',

],

# Other configurations...

linkflags = [

    # Other flags...

    '-fsanitize=address -static-libasan',

]

)

此外,需要注意的是,使用 AddressSanitizer 时,不能链接其他的内存管理库,例如 tcmalloc/jemalloc

请问这个'-fsanitize=address -static-libasan', 对gcc的版本有要求吗? Linking Shared Library build64_release/app/brand/common/libdatetime.so g++: error: unrecognized command line option '-fsanitize=address -static-libasan'

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/chen3feng/blade-build/issues/578#issuecomment-651676929, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPH4SVMKBJ2T6OXZSADRNTRZGV3JANCNFSM4J7CRMNQ .