From a814516a08c7fba50be8a8100f985473972dffbc Mon Sep 17 00:00:00 2001 From: machenbach Date: Wed, 27 May 2015 09:18:22 -0700 Subject: [PATCH] [test] Add sanitizer coverage to gyp configs. BUG=chromium:489254 LOG=n Review URL: https://codereview.chromium.org/1158903002 Cr-Commit-Position: refs/heads/master@{#28663} --- build/standalone.gypi | 85 ++++++++++++++++++++++++++++++------------- 1 file changed, 59 insertions(+), 26 deletions(-) diff --git a/build/standalone.gypi b/build/standalone.gypi index c01c802386..dc4ce0084a 100644 --- a/build/standalone.gypi +++ b/build/standalone.gypi @@ -76,6 +76,10 @@ 'lsan%': 0, 'msan%': 0, 'tsan%': 0, + # Enable coverage gathering instrumentation in sanitizer tools. This flag + # also controls coverage granularity (1 for function-level, 2 for + # block-level, 3 for edge-level). + 'sanitizer_coverage%': 0, # goma settings. # 1 to use goma. @@ -101,6 +105,7 @@ 'lsan%': '<(lsan)', 'msan%': '<(msan)', 'tsan%': '<(tsan)', + 'sanitizer_coverage%': '<(sanitizer_coverage)', # Add a simple extra solely for the purpose of the cctests 'v8_extra_library_files': ['../test/cctest/test-extra.js'], @@ -321,7 +326,6 @@ }], ], }], - # TODO(machenbach): Add sanitizer coverage. ['lsan==1', { 'target_conditions': [ ['_toolset=="target"', { @@ -377,35 +381,64 @@ '<(DEPTH)/buildtools/third_party/libc++/libc++.gyp:libcxx_proxy', ], }], - ], - }, - }], - ['asan==1 and OS=="mac"', { - 'target_defaults': { - 'xcode_settings': { - 'OTHER_CFLAGS+': [ - '-fno-omit-frame-pointer', - '-gline-tables-only', - '-fsanitize=address', - '-w', # http://crbug.com/162783 - ], - 'OTHER_CFLAGS!': [ - '-fomit-frame-pointer', - ], - 'defines': [ - 'ADDRESS_SANITIZER', - ], - }, - 'target_conditions': [ - ['_type!="static_library"', { - 'xcode_settings': {'OTHER_LDFLAGS': ['-fsanitize=address']}, + ['sanitizer_coverage!=0', { + 'target_conditions': [ + ['_toolset=="target"', { + 'cflags': [ + '-fsanitize-coverage=<(sanitizer_coverage)', + ], + 'defines': [ + 'SANITIZER_COVERAGE', + ], + }], + ], }], ], - 'dependencies': [ - '<(DEPTH)/build/mac/asan.gyp:asan_dynamic_runtime', - ], }, }], + ['OS=="mac"', { + 'target_defaults': { + 'conditions': [ + ['asan==1', { + 'xcode_settings': { + # FIXME(machenbach): This is outdated compared to common.gypi. + 'OTHER_CFLAGS+': [ + '-fno-omit-frame-pointer', + '-gline-tables-only', + '-fsanitize=address', + '-w', # http://crbug.com/162783 + ], + 'OTHER_CFLAGS!': [ + '-fomit-frame-pointer', + ], + 'defines': [ + 'ADDRESS_SANITIZER', + ], + }, + 'dependencies': [ + '<(DEPTH)/build/mac/asan.gyp:asan_dynamic_runtime', + ], + 'target_conditions': [ + ['_type!="static_library"', { + 'xcode_settings': {'OTHER_LDFLAGS': ['-fsanitize=address']}, + }], + ], + }], + ['sanitizer_coverage!=0', { + 'target_conditions': [ + ['_toolset=="target"', { + 'cflags': [ + '-fsanitize-coverage=<(sanitizer_coverage)', + ], + 'defines': [ + 'SANITIZER_COVERAGE', + ], + }], + ], + }], + ], + }, # target_defaults + }], # OS=="mac" ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \ or OS=="netbsd" or OS=="aix"', { 'target_defaults': {