Page MenuHome

Support ASan library on macOS for all generators.
ClosedPublic

Authored by Ankit Meel (ankitm) on Sep 6 2020, 1:16 PM.

Details

Summary

This change allows macOS developers to use
WITH_COMPILER_ASAN with every generator.

CMAKE_C_IMPLICIT_LINK_DIRECTORIES on macOS points to
Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/lib
which is not where the Sanitizer libraries are.

To link the library, rpath could be used but that seems complex,
so linker flags are passed as the documentation says. [1]

If users have ASAN_OPTIONS=detect_leaks=1 in their environment
variables, it should be removed to avoid a feature-unsupported error
while compiling.

[1]: http://clang.llvm.org/docs/AddressSanitizer.html#usage

Diff Detail

Repository
rB Blender
Branch
asanxcode (branched from master)
Build Status
Buildable 10002
Build 10002: arc lint + arc unit

Event Timeline

Ankit Meel (ankitm) requested review of this revision.Sep 6 2020, 1:16 PM
Ankit Meel (ankitm) created this revision.
  • Fix formatting, and use find_library() itself.

Another way to do this change was

set(CMAKE_XCODE_GENERATE_SCHEME ON)
# Uncheck some boxes so that ASan can be enabled.
set(CMAKE_XCODE_SCHEME_GUARD_MALLOC OFF)
set(CMAKE_XCODE_SCHEME_MALLOC_GUARD_EDGES OFF)
set(CMAKE_XCODE_SCHEME_ADDRESS_SANITIZER ON)
set(CMAKE_XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN ON)

But it would not be helpful for Ninja and Unix-makefiles.

CMakeLists.txt
543–547

Should execute_process be moved to platform_apple.cmake ?

Ankit Meel (ankitm) marked an inline comment as not done.Sep 6 2020, 4:17 PM
  • Not abuse compile flags for linker. unset variable.
This revision is now accepted and ready to land.Sep 7 2020, 6:38 PM
Ankit Meel (ankitm) retitled this revision from Enable ASan library on macOS for all generators. to Support ASan library on macOS for all generators..Sep 7 2020, 8:46 PM
Ankit Meel (ankitm) edited the summary of this revision. (Show Details)