From 632199ec6e2b99beb87a2cb52969f00e61e5a138 Mon Sep 17 00:00:00 2001 From: mtklein Date: Wed, 9 Dec 2015 12:39:01 -0800 Subject: [PATCH] Make skia_sanitizer work on Macs too. This is of course limited by what the compiler suppports. -fsanitize=address seems to work OK. BUG=skia: Review URL: https://codereview.chromium.org/1512853005 --- gyp/common_conditions.gypi | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/gyp/common_conditions.gypi b/gyp/common_conditions.gypi index 5fb45f6..8221c94 100644 --- a/gyp/common_conditions.gypi +++ b/gyp/common_conditions.gypi @@ -434,18 +434,14 @@ }], # Enable asan, tsan, etc. [ 'skia_sanitizer', { + 'cflags_cc!': [ '-fno-rtti' ], # vptr needs rtti 'cflags': [ '-fsanitize=<(skia_sanitizer)', # Turn on sanitizers. '-fno-sanitize-recover=<(skia_sanitizer)', # Make any failure fatal. '-fsanitize-blacklist=<(skia_sanitizer_blacklist)', # Compile in our blacklist. '-include <(skia_sanitizer_blacklist)', # Make every .cpp depend on it. ], - 'cflags_cc!': [ - '-fno-rtti' - ], - 'ldflags': [ - '-fsanitize=<(skia_sanitizer)', - ], + 'ldflags': [ '-fsanitize=<(skia_sanitizer)' ], 'conditions' : [ [ 'skia_sanitizer == "thread"', { 'defines': [ 'THREAD_SANITIZER' ], @@ -507,6 +503,21 @@ }, { 'MACOSX_DEPLOYMENT_TARGET': '<(skia_osx_deployment_target)', }], + [ 'skia_sanitizer', { + 'GCC_ENABLE_CPP_RTTI': 'YES', # vptr needs rtti + 'OTHER_CFLAGS': [ + '-fsanitize=<(skia_sanitizer)', # Turn on sanitizers. + '-fno-sanitize-recover=<(skia_sanitizer)', # Make any failure fatal. + '-fsanitize-blacklist=<(skia_sanitizer_blacklist)', # Compile in our blacklist. + '-include <(skia_sanitizer_blacklist)', # Make every .cpp depend on it. + ], + # We want to pass -fsanitize=... to our final link call, + # but not to libtool. OTHER_LDFLAGS is passed to both. + # To trick GYP into doing what we want, we'll piggyback on + # LIBRARY_SEARCH_PATHS, producing "-L/usr/lib -fsanitize=...". + # The -L/usr/lib is redundant but innocuous: it's a default path. + 'LIBRARY_SEARCH_PATHS': [ '/usr/lib -fsanitize=<(skia_sanitizer)'], + }], ], 'CLANG_CXX_LIBRARY': 'libc++', 'CLANG_CXX_LANGUAGE_STANDARD': 'c++11', -- 2.7.4