<small id='QHvzF'></small><noframes id='QHvzF'>

    <i id='QHvzF'><tr id='QHvzF'><dt id='QHvzF'><q id='QHvzF'><span id='QHvzF'><b id='QHvzF'><form id='QHvzF'><ins id='QHvzF'></ins><ul id='QHvzF'></ul><sub id='QHvzF'></sub></form><legend id='QHvzF'></legend><bdo id='QHvzF'><pre id='QHvzF'><center id='QHvzF'></center></pre></bdo></b><th id='QHvzF'></th></span></q></dt></tr></i><div id='QHvzF'><tfoot id='QHvzF'></tfoot><dl id='QHvzF'><fieldset id='QHvzF'></fieldset></dl></div>

    <tfoot id='QHvzF'></tfoot>
  1. <legend id='QHvzF'><style id='QHvzF'><dir id='QHvzF'><q id='QHvzF'></q></dir></style></legend>
      <bdo id='QHvzF'></bdo><ul id='QHvzF'></ul>

    1. 在适用于 Xcode 的 CMake 中启用 AddressSanitizer 的正确方法是什么

      What#39;s the proper way to enable AddressSanitizer in CMake that works in Xcode(在适用于 Xcode 的 CMake 中启用 AddressSanitizer 的正确方法是什么)
      <i id='n52RI'><tr id='n52RI'><dt id='n52RI'><q id='n52RI'><span id='n52RI'><b id='n52RI'><form id='n52RI'><ins id='n52RI'></ins><ul id='n52RI'></ul><sub id='n52RI'></sub></form><legend id='n52RI'></legend><bdo id='n52RI'><pre id='n52RI'><center id='n52RI'></center></pre></bdo></b><th id='n52RI'></th></span></q></dt></tr></i><div id='n52RI'><tfoot id='n52RI'></tfoot><dl id='n52RI'><fieldset id='n52RI'></fieldset></dl></div>

      <tfoot id='n52RI'></tfoot>
        • <bdo id='n52RI'></bdo><ul id='n52RI'></ul>
        • <small id='n52RI'></small><noframes id='n52RI'>

              <legend id='n52RI'><style id='n52RI'><dir id='n52RI'><q id='n52RI'></q></dir></style></legend>

                  <tbody id='n52RI'></tbody>
              1. 本文介绍了在适用于 Xcode 的 CMake 中启用 AddressSanitizer 的正确方法是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我添加了 AddressSanitizer 标志如下:

                I've added AddressSanitizer flag as follow:

                set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
                

                使用 Unix Makefiles 时,一切构建和运行良好.

                Everything builds and runs fine when using Unix Makefiles.

                问题是在生成Xcode项目的时候,它只是不想链接,因为它找不到ASan库.

                The problem comes when generating the Xcode project, it just doesn't want to link because it cannot find the ASan library.

                我已经找到了两个解决方案,但决定不使用它们,因为它们无法仅使用 CMake 实现自动化:

                I already found two solutions, but decided not to use them because they cannot be automated using just CMake:

                1. -Wl,-undefined,dynamic_lookup 添加到链接标志,因此它跳过链接到动态库.
                2. 直接与 libclang_rt.asan_osx_dynamic.dylib 链接.
                1. Adding -Wl,-undefined,dynamic_lookup to the linked flags, so it skips linking to dynamic libraries.
                2. Link with libclang_rt.asan_osx_dynamic.dylib directly.

                那么这两种解决方案有什么问题?

                So what's the problem with these two solutions?

                • 使用解决方案 #1 时,我必须在 Xcode 中手动打开目标方案并添加指向 libclang_rt.asan_osx_dynamic.dylibDYLD_INSERT_LIBRARIES 环境变量.
                • 使用解决方案 #2 时,ASan 库的路径因计算机而异.

                此外,作为另一种解决方案,我尝试从 Xcode 目标方案启用 Address Sanitizer 标志,但有趣的是它没有检测到我添加的问题,所以我没有将其列为解决方案,因为它没有通过我的测试.

                Additionally as another solution, I tried enabling Address Sanitizer flag from the Xcode target scheme but interestingly it didn't detect the issues I added, so I didn't list this as a solution because it failed my test.

                任何帮助将不胜感激.

                推荐答案

                您也需要向链接器提供标志.我是这样做的:

                You need to provide the flag(s) to the linker too. I'm doing it like this:

                set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
                set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
                

                这篇关于在适用于 Xcode 的 CMake 中启用 AddressSanitizer 的正确方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                What is inside .lib file of Static library, Statically linked dynamic library and dynamically linked dynamic library?(静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么?)
                How do I load a C DLL from the SXS in Python?(如何从 Python 中的 SXS 加载 C DLL?)
                Can Cython code be compiled to a dll so C++ application can call it?(Cython 代码可以编译成 dll 以便 C++ 应用程序可以调用它吗?)
                Delay Loading DLLs(延迟加载 DLL)
                Throwing C++ exceptions across DLL boundaries(跨 DLL 边界抛出 C++ 异常)
                Loading a dll from a dll?(从 dll 加载 dll?)

                    <tfoot id='MdhE9'></tfoot>

                    <small id='MdhE9'></small><noframes id='MdhE9'>

                      <i id='MdhE9'><tr id='MdhE9'><dt id='MdhE9'><q id='MdhE9'><span id='MdhE9'><b id='MdhE9'><form id='MdhE9'><ins id='MdhE9'></ins><ul id='MdhE9'></ul><sub id='MdhE9'></sub></form><legend id='MdhE9'></legend><bdo id='MdhE9'><pre id='MdhE9'><center id='MdhE9'></center></pre></bdo></b><th id='MdhE9'></th></span></q></dt></tr></i><div id='MdhE9'><tfoot id='MdhE9'></tfoot><dl id='MdhE9'><fieldset id='MdhE9'></fieldset></dl></div>
                      • <legend id='MdhE9'><style id='MdhE9'><dir id='MdhE9'><q id='MdhE9'></q></dir></style></legend>
                          <tbody id='MdhE9'></tbody>

                          <bdo id='MdhE9'></bdo><ul id='MdhE9'></ul>