From bf04c203dbf0b4bbb166fdb73f7addcdc70a9b22 Mon Sep 17 00:00:00 2001 From: Oliver Chang Date: Mon, 24 Jul 2023 12:35:02 +1000 Subject: [PATCH] Support jcc for cloud experiments. (#10738) --- infra/build/functions/build_project.py | 9 ++++++++- infra/build/functions/target_experiment.py | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/infra/build/functions/build_project.py b/infra/build/functions/build_project.py index e865f2852..78cc42d4c 100755 --- a/infra/build/functions/build_project.py +++ b/infra/build/functions/build_project.py @@ -305,7 +305,11 @@ def get_id(step_type, build): def get_build_steps( # pylint: disable=too-many-locals, too-many-statements, too-many-branches, too-many-arguments - project_name, project_yaml, dockerfile, config): + project_name, + project_yaml, + dockerfile, + config, + additional_env=None): """Returns build steps for project.""" project = Project(project_name, project_yaml, dockerfile) @@ -336,6 +340,9 @@ def get_build_steps( # pylint: disable=too-many-locals, too-many-statements, to continue env = get_env(project.fuzzing_language, build) + if additional_env: + env.extend(additional_env) + compile_step = get_compile_step(project, build, env, config.parallel, config.upload_build_logs) build_steps.append(compile_step) diff --git a/infra/build/functions/target_experiment.py b/infra/build/functions/target_experiment.py index 8870e6177..902ef1cd5 100644 --- a/infra/build/functions/target_experiment.py +++ b/infra/build/functions/target_experiment.py @@ -25,6 +25,8 @@ import google.auth import build_lib import build_project +JCC_DIR = '/usr/local/bin/jcc' + def run_experiment(project_name, target_name, args, output_path, build_output_path, upload_corpus_path, upload_coverage_path, @@ -58,8 +60,15 @@ def run_experiment(project_name, target_name, args, output_path, # Don't do bad build checks. project_yaml['run_tests'] = False - steps = build_project.get_build_steps(project_name, project_yaml, - dockerfile_contents, config) + jcc_env = [ + f'CC={JCC_DIR}/clang', + f'CXX={JCC_DIR}/clang++', + ] + steps = build_project.get_build_steps(project_name, + project_yaml, + dockerfile_contents, + config, + additional_env=jcc_env) build = build_project.Build('libfuzzer', 'address', 'x86_64') local_output_path = '/workspace/output.log' @@ -109,6 +118,7 @@ def run_experiment(project_name, target_name, args, output_path, # Build for coverage. build = build_project.Build('libfuzzer', 'coverage', 'x86_64') env = build_project.get_env(project_yaml['language'], build) + env.extend(jcc_env) steps.append( build_project.get_compile_step(project, build, env, config.parallel))