diff --git a/infra/build/functions/build_lib.py b/infra/build/functions/build_lib.py index 58183ef66..beb937c94 100644 --- a/infra/build/functions/build_lib.py +++ b/infra/build/functions/build_lib.py @@ -442,7 +442,8 @@ def get_project_image_steps( # pylint: disable=too-many-arguments config, architectures=None, experiment=False, - cache_image=None): + cache_image=None, + srcmap=True): """Returns GCB steps to build OSS-Fuzz project image.""" if architectures is None: architectures = [] @@ -459,29 +460,25 @@ def get_project_image_steps( # pylint: disable=too-many-arguments steps.extend(get_pull_test_images_steps(config.test_image_suffix)) src_root = 'oss-fuzz' if not experiment else '.' - steps.append({ - 'name': 'ubuntu', - 'args': ['bash', '-c', f'cat {src_root}/projects/{name}/Dockerfile'], - }) - docker_build_step = get_docker_build_step([image], os.path.join('projects', name), src_root=src_root, cache_image=cache_image) steps.append(docker_build_step) - srcmap_step_id = get_srcmap_step_id() - steps.extend([{ - 'name': image, - 'args': [ - 'bash', '-c', - 'srcmap > /workspace/srcmap.json && cat /workspace/srcmap.json' - ], - 'env': [ - 'OSSFUZZ_REVISION=$REVISION_ID', - 'FUZZING_LANGUAGE=%s' % language, - ], - 'id': srcmap_step_id - }]) + if srcmap: + srcmap_step_id = get_srcmap_step_id() + steps.extend([{ + 'name': image, + 'args': [ + 'bash', '-c', + 'srcmap > /workspace/srcmap.json && cat /workspace/srcmap.json' + ], + 'env': [ + 'OSSFUZZ_REVISION=$REVISION_ID', + 'FUZZING_LANGUAGE=%s' % language, + ], + 'id': srcmap_step_id + }]) if has_arm_build(architectures): builder_name = 'buildxbuilder' diff --git a/infra/build/functions/build_project.py b/infra/build/functions/build_project.py index 3878bd086..b8eca8eb0 100755 --- a/infra/build/functions/build_project.py +++ b/infra/build/functions/build_project.py @@ -354,22 +354,19 @@ def get_build_steps_for_project(project, timestamp = get_datetime_now().strftime('%Y%m%d%H%M') - # If we use caching, then we need to use the right name. We assume that - # there is only a single sanitizer. if use_caching: - project.cached_sanitizer = project.sanitizers[0] - cache_image = project.cached_image + # For cached builds: the cache images are sanitizer-specific, so we need to + # do a rebuild prior to each compile. + build_steps = [] else: - cache_image = None - - build_steps = build_lib.get_project_image_steps( - project.name, - project.image, - project.fuzzing_language, - config=config, - architectures=project.architectures, - experiment=config.experiment, - cache_image=cache_image) + # Non-cached builds just use a single builder image to build all sanitizers. + build_steps = build_lib.get_project_image_steps( + project.name, + project.image, + project.fuzzing_language, + config=config, + architectures=project.architectures, + experiment=config.experiment) # Sort engines to make AFL first to test if libFuzzer has an advantage in # finding bugs first since it is generally built first. @@ -379,6 +376,15 @@ def get_build_steps_for_project(project, for sanitizer in sorted(project.sanitizers): if use_caching and sanitizer in _CACHED_SANITIZERS: project.cached_sanitizer = sanitizer + build_steps.extend( + build_lib.get_project_image_steps( + project.name, + project.image, + project.fuzzing_language, + config=config, + architectures=project.architectures, + experiment=config.experiment, + cache_image=project.cached_image)) # Build x86_64 before i386. for architecture in reversed(sorted(project.architectures)): diff --git a/infra/build/functions/target_experiment.py b/infra/build/functions/target_experiment.py index 4b7e2687f..a918920bc 100644 --- a/infra/build/functions/target_experiment.py +++ b/infra/build/functions/target_experiment.py @@ -220,6 +220,15 @@ def run_experiment(project_name, if use_cached_image: project.cached_sanitizer = 'coverage' + steps.extend( + build_lib.get_project_image_steps(project.name, + project.image, + project.fuzzing_language, + config=config, + architectures=project.architectures, + experiment=config.experiment, + cache_image=project.cached_image, + srcmap=False)) steps.append( build_project.get_compile_step(project, build, env, config.parallel))