Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(497)

Unified Diff: infra/bots/recipe_modules/flavor/gn_flavor.py

Issue 2289343002: GN: add sanitize arg (Closed)
Patch Set: rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: infra/bots/recipe_modules/flavor/gn_flavor.py
diff --git a/infra/bots/recipe_modules/flavor/gn_flavor.py b/infra/bots/recipe_modules/flavor/gn_flavor.py
index 3154ef3425acc738fbabd11b00de3bc5029ea3fc..61b12a1262c46df9031befc95ec0a7abb1764f47 100644
--- a/infra/bots/recipe_modules/flavor/gn_flavor.py
+++ b/infra/bots/recipe_modules/flavor/gn_flavor.py
@@ -10,15 +10,17 @@ class GNFlavorUtils(default_flavor.DefaultFlavorUtils):
extra_config = self.m.vars.builder_cfg.get('extra_config', '')
return any([
- extra_config == 'GN',
+ 'SAN' in extra_config,
extra_config == 'Fast',
+ extra_config == 'GN',
extra_config.startswith('SK')
])
- def _run(self, title, cmd):
- path = self.m.vars.default_env['PATH']
- self.m.vars.default_env = {'PATH': path}
- self.m.run(self.m.step, title, cmd=cmd, cwd=self.m.vars.skia_dir)
+ def _run(self, title, cmd, env=None):
+ self.m.vars.default_env = {k: v for (k,v)
+ in self.m.vars.default_env.iteritems()
+ if k in ['PATH']}
+ self.m.run(self.m.step, title, cmd=cmd, env=env, cwd=self.m.vars.skia_dir)
def compile(self, unused_target, **kwargs):
"""Build Skia with GN."""
@@ -27,13 +29,15 @@ class GNFlavorUtils(default_flavor.DefaultFlavorUtils):
extra_config = self.m.vars.builder_cfg.get('extra_config', '')
os = self.m.vars.builder_cfg.get('os', '')
+ clang_linux = str(self.m.vars.slave_dir.join('clang_linux'))
borenet 2016/09/08 14:47:33 Why str() instead of using pathObj.join(...) ?
mtklein 2016/09/08 14:51:10 Just seems easier to convert to string here once t
borenet 2016/09/08 15:06:39 Ok, I'm not sure that str(pathObj) will resolve th
+
cc, cxx = None, None
extra_cflags = []
extra_ldflags = []
if compiler == 'Clang' and os == 'Ubuntu':
- cc = self.m.vars.slave_dir.join('clang_linux', 'bin', 'clang')
- cxx = self.m.vars.slave_dir.join('clang_linux', 'bin', 'clang++')
+ cc = clang_linux + '/bin/clang'
+ cxx = clang_linux + '/bin/clang++'
extra_ldflags.append('-fuse-ld=lld')
elif compiler == 'Clang':
cc, cxx = 'clang', 'clang++'
@@ -44,17 +48,22 @@ class GNFlavorUtils(default_flavor.DefaultFlavorUtils):
extra_cflags.extend(['-march=native', '-fomit-frame-pointer', '-O3'])
if extra_config.startswith('SK'):
extra_cflags.append('-D' + extra_config)
+ if extra_config == 'MSAN':
+ extra_ldflags.append('-L' + clang_linux + '/msan')
args = {}
if configuration != 'Debug':
args['is_debug'] = 'false'
+ if extra_config == 'MSAN':
+ args['skia_use_fontconfig'] = 'false'
for (k,v) in {
'cc': cc,
'cxx': cxx,
'extra_cflags': ' '.join(extra_cflags),
'extra_ldflags': ' '.join(extra_ldflags),
+ 'sanitize': extra_config if 'SAN' in extra_config else '',
}.iteritems():
if v:
args[k] = '"%s"' % v
@@ -64,3 +73,28 @@ class GNFlavorUtils(default_flavor.DefaultFlavorUtils):
self._run('fetch-gn', [self.m.vars.skia_dir.join('bin', 'fetch-gn')])
self._run('gn gen', ['gn', 'gen', self.out_dir, '--args=' + gn_args])
self._run('ninja', ['ninja', '-C', self.out_dir])
+
+ def step(self, name, cmd, env=None, **kwargs):
+ app = self.m.vars.skia_out.join(self.m.vars.configuration, cmd[0])
+ cmd = [app] + cmd[1:]
+ env = {}
+
+ clang_linux = str(self.m.vars.slave_dir.join('clang_linux'))
+ extra_config = self.m.vars.builder_cfg.get('extra_config', '')
+
+ if 'SAN' in extra_config:
+ # Sanitized binaries may want to run clang_linux/bin/llvm-symbolizer.
+ self.m.vars.default_env['PATH'] = '%%(PATH)s:%s' % clang_linux + '/bin'
+ elif 'Ubuntu' == self.m.vars.builder_cfg.get('os', ''):
+ cmd = ['catchsegv'] + cmd
+
+ if 'ASAN' == extra_config:
+ env[ 'ASAN_OPTIONS'] = 'symbolize=1 detect_leaks=1'
+ env[ 'LSAN_OPTIONS'] = 'symbolize=1 print_suppressions=1'
+ env['UBSAN_OPTIONS'] = 'symbolize=1 print_stacktrace=1'
+
+ if 'MSAN' == extra_config:
+ # Find the MSAN-built libc++.
+ env['LD_LIBRARY_PATH'] = clang_linux + '/msan'
+
+ self._run(name, cmd, env=env)

Powered by Google App Engine
This is Rietveld 408576698