Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

Commit

Permalink
Add 'osx-10-11-sanitize-address' (Xcode) toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslo committed Sep 28, 2016
1 parent 915b572 commit 2dd469e
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
1 change: 1 addition & 0 deletions bin/detail/toolchain_table.py
Expand Up @@ -292,6 +292,7 @@ def verify(self):
Toolchain('osx-10-11', 'Xcode', osx_version='10.11'),
Toolchain('osx-10-10-dep-10-7', 'Xcode', osx_version='10.10'),
Toolchain('osx-10-10-dep-10-9-make', 'Unix Makefiles'),
Toolchain('osx-10-11-sanitize-address', 'Xcode', osx_version='10.11'),
Toolchain('linux-gcc-x64', 'Unix Makefiles'),
]

Expand Down
35 changes: 35 additions & 0 deletions flags/sanitize_address.cmake
Expand Up @@ -8,6 +8,7 @@ else()
endif()

include(polly_add_cache_flag)
include(polly_fatal_error)

polly_add_cache_flag(CMAKE_CXX_FLAGS "-fsanitize=address")
polly_add_cache_flag(CMAKE_CXX_FLAGS "-g")
Expand All @@ -32,3 +33,37 @@ set(
"C compiler flags"
FORCE
)

if(XCODE)
polly_add_cache_flag(CMAKE_C_FLAGS "-D_LIBCPP_HAS_NO_ASAN")
polly_add_cache_flag(CMAKE_CXX_FLAGS "-D_LIBCPP_HAS_NO_ASAN")

string(COMPARE EQUAL "${CMAKE_XCODE_ATTRIBUTE_CC}" "" _is_empty)
if(_is_empty)
polly_fatal_error("CMAKE_XCODE_ATTRIBUTE_CC is empty")
endif()

get_filename_component(_xcode_root "${CMAKE_XCODE_ATTRIBUTE_CC}" DIRECTORY)

set(_xcode_asan_lib_name "libclang_rt.asan_osx_dynamic")
set(
_xcode_asan_pattern
"${_xcode_root}/../lib/clang/*/lib/darwin/${_xcode_asan_lib_name}.dylib"
)

file(GLOB _xcode_asan_lib "${_xcode_asan_pattern}")
list(LENGTH _xcode_asan_lib _xcode_asan_lib_length)
if(_xcode_asan_lib_length EQUAL 1)
get_filename_component(_xcode_asan_lib "${_xcode_asan_lib}" ABSOLUTE)
get_filename_component(_xcode_asan_lib_dir "${_xcode_asan_lib}" DIRECTORY)
polly_status_debug("Using ASAN library:\n")
polly_status_debug(" * ${_xcode_asan_lib}")
elseif(_xcode_asan_lib_length EQUAL 0)
polly_fatal_error("File not found by pattern: ${_xcode_asan_pattern}")
else()
polly_fatal_error("Unexpected: '${_xcode_asan_lib}'")
endif()

polly_add_cache_flag(CMAKE_EXE_LINKER_FLAGS "${_xcode_asan_lib}")
polly_add_cache_flag(CMAKE_SHARED_LINKER_FLAGS "${_xcode_asan_lib}")
endif()
30 changes: 30 additions & 0 deletions osx-10-11-sanitize-address.cmake
@@ -0,0 +1,30 @@
# Copyright (c) 2016, Ruslan Baratov
# All rights reserved.

if(DEFINED POLLY_OSX_10_11_SANITIZE_ADDRESS_CMAKE_)
return()
else()
set(POLLY_OSX_10_11_SANITIZE_ADDRESS_CMAKE_ 1)
endif()

include("${CMAKE_CURRENT_LIST_DIR}/utilities/polly_init.cmake")

set(OSX_SDK_VERSION "10.11")
set(POLLY_XCODE_COMPILER "clang")
polly_init(
"Xcode (OS X ${OSX_SDK_VERSION}) / \
${POLLY_XCODE_COMPILER} / \
LLVM Standard C++ Library (libc++) / Clang address sanitizer / c++11 support"
"Xcode"
)

include("${CMAKE_CURRENT_LIST_DIR}/utilities/polly_common.cmake")

include("${CMAKE_CURRENT_LIST_DIR}/compiler/xcode.cmake")

set(CMAKE_OSX_DEPLOYMENT_TARGET "10.11" CACHE STRING "OS X Deployment target" FORCE)

include("${CMAKE_CURRENT_LIST_DIR}/library/std/libcxx.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/flags/cxx11.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/os/osx.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/flags/sanitize_address.cmake")

0 comments on commit 2dd469e

Please sign in to comment.