spirv-fuzz: support building using gn (#4365)

Adds support for building spirv-fuzz using gn. Updates the protobuf
dependency to the version used by Chromium.

Fixes #4372.
This commit is contained in:
Alastair Donaldson 2021-07-13 19:45:01 +01:00 committed by GitHub
parent d432bebb11
commit 2299b710de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 461 additions and 14 deletions

443
BUILD.gn
View File

@ -14,6 +14,7 @@
import("//build_overrides/build.gni")
import("//build_overrides/spirv_tools.gni")
import("//third_party/protobuf/proto_library.gni")
if (build_with_chromium) {
import("//testing/test.gni")
}
@ -449,8 +450,12 @@ static_library("spvtools") {
"source/spirv_definition.h",
"source/spirv_endian.cpp",
"source/spirv_endian.h",
"source/spirv_fuzzer_options.cpp",
"source/spirv_fuzzer_options.h",
"source/spirv_optimizer_options.cpp",
"source/spirv_optimizer_options.h",
"source/spirv_reducer_options.cpp",
"source/spirv_reducer_options.h",
"source/spirv_target_env.cpp",
"source/spirv_target_env.h",
"source/spirv_validator_options.cpp",
@ -860,8 +865,6 @@ static_library("spvtools_reduce") {
"source/reduce/structured_loop_to_selection_reduction_opportunity.h",
"source/reduce/structured_loop_to_selection_reduction_opportunity_finder.cpp",
"source/reduce/structured_loop_to_selection_reduction_opportunity_finder.h",
"source/spirv_reducer_options.cpp",
"source/spirv_reducer_options.h",
]
deps = [
":spvtools",
@ -875,6 +878,417 @@ static_library("spvtools_reduce") {
configs += [ ":spvtools_internal_config" ]
}
proto_library("spvtools_fuzz_proto") {
sources = [
"source/fuzz/protobufs/spvtoolsfuzz.proto",
]
generate_python = false
use_protobuf_full = true
}
static_library("spvtools_fuzz") {
sources = [
"source/fuzz/added_function_reducer.cpp",
"source/fuzz/added_function_reducer.h",
"source/fuzz/available_instructions.cpp",
"source/fuzz/available_instructions.h",
"source/fuzz/call_graph.cpp",
"source/fuzz/call_graph.h",
"source/fuzz/comparator_deep_blocks_first.h",
"source/fuzz/counter_overflow_id_source.cpp",
"source/fuzz/counter_overflow_id_source.h",
"source/fuzz/data_descriptor.cpp",
"source/fuzz/data_descriptor.h",
"source/fuzz/equivalence_relation.h",
"source/fuzz/fact_manager/constant_uniform_facts.cpp",
"source/fuzz/fact_manager/constant_uniform_facts.h",
"source/fuzz/fact_manager/data_synonym_and_id_equation_facts.cpp",
"source/fuzz/fact_manager/data_synonym_and_id_equation_facts.h",
"source/fuzz/fact_manager/dead_block_facts.cpp",
"source/fuzz/fact_manager/dead_block_facts.h",
"source/fuzz/fact_manager/fact_manager.cpp",
"source/fuzz/fact_manager/fact_manager.h",
"source/fuzz/fact_manager/irrelevant_value_facts.cpp",
"source/fuzz/fact_manager/irrelevant_value_facts.h",
"source/fuzz/fact_manager/livesafe_function_facts.cpp",
"source/fuzz/fact_manager/livesafe_function_facts.h",
"source/fuzz/force_render_red.cpp",
"source/fuzz/force_render_red.h",
"source/fuzz/fuzzer.cpp",
"source/fuzz/fuzzer.h",
"source/fuzz/fuzzer_context.cpp",
"source/fuzz/fuzzer_context.h",
"source/fuzz/fuzzer_pass.cpp",
"source/fuzz/fuzzer_pass.h",
"source/fuzz/fuzzer_pass_add_access_chains.cpp",
"source/fuzz/fuzzer_pass_add_access_chains.h",
"source/fuzz/fuzzer_pass_add_bit_instruction_synonyms.cpp",
"source/fuzz/fuzzer_pass_add_bit_instruction_synonyms.h",
"source/fuzz/fuzzer_pass_add_composite_extract.cpp",
"source/fuzz/fuzzer_pass_add_composite_extract.h",
"source/fuzz/fuzzer_pass_add_composite_inserts.cpp",
"source/fuzz/fuzzer_pass_add_composite_inserts.h",
"source/fuzz/fuzzer_pass_add_composite_types.cpp",
"source/fuzz/fuzzer_pass_add_composite_types.h",
"source/fuzz/fuzzer_pass_add_copy_memory.cpp",
"source/fuzz/fuzzer_pass_add_copy_memory.h",
"source/fuzz/fuzzer_pass_add_dead_blocks.cpp",
"source/fuzz/fuzzer_pass_add_dead_blocks.h",
"source/fuzz/fuzzer_pass_add_dead_breaks.cpp",
"source/fuzz/fuzzer_pass_add_dead_breaks.h",
"source/fuzz/fuzzer_pass_add_dead_continues.cpp",
"source/fuzz/fuzzer_pass_add_dead_continues.h",
"source/fuzz/fuzzer_pass_add_equation_instructions.cpp",
"source/fuzz/fuzzer_pass_add_equation_instructions.h",
"source/fuzz/fuzzer_pass_add_function_calls.cpp",
"source/fuzz/fuzzer_pass_add_function_calls.h",
"source/fuzz/fuzzer_pass_add_global_variables.cpp",
"source/fuzz/fuzzer_pass_add_global_variables.h",
"source/fuzz/fuzzer_pass_add_image_sample_unused_components.cpp",
"source/fuzz/fuzzer_pass_add_image_sample_unused_components.h",
"source/fuzz/fuzzer_pass_add_loads.cpp",
"source/fuzz/fuzzer_pass_add_loads.h",
"source/fuzz/fuzzer_pass_add_local_variables.cpp",
"source/fuzz/fuzzer_pass_add_local_variables.h",
"source/fuzz/fuzzer_pass_add_loop_preheaders.cpp",
"source/fuzz/fuzzer_pass_add_loop_preheaders.h",
"source/fuzz/fuzzer_pass_add_loops_to_create_int_constant_synonyms.cpp",
"source/fuzz/fuzzer_pass_add_loops_to_create_int_constant_synonyms.h",
"source/fuzz/fuzzer_pass_add_no_contraction_decorations.cpp",
"source/fuzz/fuzzer_pass_add_no_contraction_decorations.h",
"source/fuzz/fuzzer_pass_add_opphi_synonyms.cpp",
"source/fuzz/fuzzer_pass_add_opphi_synonyms.h",
"source/fuzz/fuzzer_pass_add_parameters.cpp",
"source/fuzz/fuzzer_pass_add_parameters.h",
"source/fuzz/fuzzer_pass_add_relaxed_decorations.cpp",
"source/fuzz/fuzzer_pass_add_relaxed_decorations.h",
"source/fuzz/fuzzer_pass_add_stores.cpp",
"source/fuzz/fuzzer_pass_add_stores.h",
"source/fuzz/fuzzer_pass_add_synonyms.cpp",
"source/fuzz/fuzzer_pass_add_synonyms.h",
"source/fuzz/fuzzer_pass_add_vector_shuffle_instructions.cpp",
"source/fuzz/fuzzer_pass_add_vector_shuffle_instructions.h",
"source/fuzz/fuzzer_pass_adjust_branch_weights.cpp",
"source/fuzz/fuzzer_pass_adjust_branch_weights.h",
"source/fuzz/fuzzer_pass_adjust_function_controls.cpp",
"source/fuzz/fuzzer_pass_adjust_function_controls.h",
"source/fuzz/fuzzer_pass_adjust_loop_controls.cpp",
"source/fuzz/fuzzer_pass_adjust_loop_controls.h",
"source/fuzz/fuzzer_pass_adjust_memory_operands_masks.cpp",
"source/fuzz/fuzzer_pass_adjust_memory_operands_masks.h",
"source/fuzz/fuzzer_pass_adjust_selection_controls.cpp",
"source/fuzz/fuzzer_pass_adjust_selection_controls.h",
"source/fuzz/fuzzer_pass_apply_id_synonyms.cpp",
"source/fuzz/fuzzer_pass_apply_id_synonyms.h",
"source/fuzz/fuzzer_pass_construct_composites.cpp",
"source/fuzz/fuzzer_pass_construct_composites.h",
"source/fuzz/fuzzer_pass_copy_objects.cpp",
"source/fuzz/fuzzer_pass_copy_objects.h",
"source/fuzz/fuzzer_pass_donate_modules.cpp",
"source/fuzz/fuzzer_pass_donate_modules.h",
"source/fuzz/fuzzer_pass_duplicate_regions_with_selections.cpp",
"source/fuzz/fuzzer_pass_duplicate_regions_with_selections.h",
"source/fuzz/fuzzer_pass_expand_vector_reductions.cpp",
"source/fuzz/fuzzer_pass_expand_vector_reductions.h",
"source/fuzz/fuzzer_pass_flatten_conditional_branches.cpp",
"source/fuzz/fuzzer_pass_flatten_conditional_branches.h",
"source/fuzz/fuzzer_pass_inline_functions.cpp",
"source/fuzz/fuzzer_pass_inline_functions.h",
"source/fuzz/fuzzer_pass_interchange_signedness_of_integer_operands.cpp",
"source/fuzz/fuzzer_pass_interchange_signedness_of_integer_operands.h",
"source/fuzz/fuzzer_pass_interchange_zero_like_constants.cpp",
"source/fuzz/fuzzer_pass_interchange_zero_like_constants.h",
"source/fuzz/fuzzer_pass_invert_comparison_operators.cpp",
"source/fuzz/fuzzer_pass_invert_comparison_operators.h",
"source/fuzz/fuzzer_pass_make_vector_operations_dynamic.cpp",
"source/fuzz/fuzzer_pass_make_vector_operations_dynamic.h",
"source/fuzz/fuzzer_pass_merge_blocks.cpp",
"source/fuzz/fuzzer_pass_merge_blocks.h",
"source/fuzz/fuzzer_pass_merge_function_returns.cpp",
"source/fuzz/fuzzer_pass_merge_function_returns.h",
"source/fuzz/fuzzer_pass_mutate_pointers.cpp",
"source/fuzz/fuzzer_pass_mutate_pointers.h",
"source/fuzz/fuzzer_pass_obfuscate_constants.cpp",
"source/fuzz/fuzzer_pass_obfuscate_constants.h",
"source/fuzz/fuzzer_pass_outline_functions.cpp",
"source/fuzz/fuzzer_pass_outline_functions.h",
"source/fuzz/fuzzer_pass_permute_blocks.cpp",
"source/fuzz/fuzzer_pass_permute_blocks.h",
"source/fuzz/fuzzer_pass_permute_function_parameters.cpp",
"source/fuzz/fuzzer_pass_permute_function_parameters.h",
"source/fuzz/fuzzer_pass_permute_function_variables.cpp",
"source/fuzz/fuzzer_pass_permute_function_variables.h",
"source/fuzz/fuzzer_pass_permute_instructions.cpp",
"source/fuzz/fuzzer_pass_permute_instructions.h",
"source/fuzz/fuzzer_pass_permute_phi_operands.cpp",
"source/fuzz/fuzzer_pass_permute_phi_operands.h",
"source/fuzz/fuzzer_pass_propagate_instructions_down.cpp",
"source/fuzz/fuzzer_pass_propagate_instructions_down.h",
"source/fuzz/fuzzer_pass_propagate_instructions_up.cpp",
"source/fuzz/fuzzer_pass_propagate_instructions_up.h",
"source/fuzz/fuzzer_pass_push_ids_through_variables.cpp",
"source/fuzz/fuzzer_pass_push_ids_through_variables.h",
"source/fuzz/fuzzer_pass_replace_adds_subs_muls_with_carrying_extended.cpp",
"source/fuzz/fuzzer_pass_replace_adds_subs_muls_with_carrying_extended.h",
"source/fuzz/fuzzer_pass_replace_branches_from_dead_blocks_with_exits.cpp",
"source/fuzz/fuzzer_pass_replace_branches_from_dead_blocks_with_exits.h",
"source/fuzz/fuzzer_pass_replace_copy_memories_with_loads_stores.cpp",
"source/fuzz/fuzzer_pass_replace_copy_memories_with_loads_stores.h",
"source/fuzz/fuzzer_pass_replace_copy_objects_with_stores_loads.cpp",
"source/fuzz/fuzzer_pass_replace_copy_objects_with_stores_loads.h",
"source/fuzz/fuzzer_pass_replace_irrelevant_ids.cpp",
"source/fuzz/fuzzer_pass_replace_irrelevant_ids.h",
"source/fuzz/fuzzer_pass_replace_linear_algebra_instructions.cpp",
"source/fuzz/fuzzer_pass_replace_linear_algebra_instructions.h",
"source/fuzz/fuzzer_pass_replace_loads_stores_with_copy_memories.cpp",
"source/fuzz/fuzzer_pass_replace_loads_stores_with_copy_memories.h",
"source/fuzz/fuzzer_pass_replace_opphi_ids_from_dead_predecessors.cpp",
"source/fuzz/fuzzer_pass_replace_opphi_ids_from_dead_predecessors.h",
"source/fuzz/fuzzer_pass_replace_opselects_with_conditional_branches.cpp",
"source/fuzz/fuzzer_pass_replace_opselects_with_conditional_branches.h",
"source/fuzz/fuzzer_pass_replace_parameter_with_global.cpp",
"source/fuzz/fuzzer_pass_replace_parameter_with_global.h",
"source/fuzz/fuzzer_pass_replace_params_with_struct.cpp",
"source/fuzz/fuzzer_pass_replace_params_with_struct.h",
"source/fuzz/fuzzer_pass_split_blocks.cpp",
"source/fuzz/fuzzer_pass_split_blocks.h",
"source/fuzz/fuzzer_pass_swap_commutable_operands.cpp",
"source/fuzz/fuzzer_pass_swap_commutable_operands.h",
"source/fuzz/fuzzer_pass_swap_conditional_branch_operands.cpp",
"source/fuzz/fuzzer_pass_swap_conditional_branch_operands.h",
"source/fuzz/fuzzer_pass_swap_functions.cpp",
"source/fuzz/fuzzer_pass_swap_functions.h",
"source/fuzz/fuzzer_pass_toggle_access_chain_instruction.cpp",
"source/fuzz/fuzzer_pass_toggle_access_chain_instruction.h",
"source/fuzz/fuzzer_pass_wrap_regions_in_selections.cpp",
"source/fuzz/fuzzer_pass_wrap_regions_in_selections.h",
"source/fuzz/fuzzer_util.cpp",
"source/fuzz/fuzzer_util.h",
"source/fuzz/id_use_descriptor.cpp",
"source/fuzz/id_use_descriptor.h",
"source/fuzz/instruction_descriptor.cpp",
"source/fuzz/instruction_descriptor.h",
"source/fuzz/instruction_message.cpp",
"source/fuzz/instruction_message.h",
"source/fuzz/overflow_id_source.cpp",
"source/fuzz/overflow_id_source.h",
"source/fuzz/pass_management/repeated_pass_instances.h",
"source/fuzz/pass_management/repeated_pass_manager.cpp",
"source/fuzz/pass_management/repeated_pass_manager.h",
"source/fuzz/pass_management/repeated_pass_manager_looped_with_recommendations.cpp",
"source/fuzz/pass_management/repeated_pass_manager_looped_with_recommendations.h",
"source/fuzz/pass_management/repeated_pass_manager_random_with_recommendations.cpp",
"source/fuzz/pass_management/repeated_pass_manager_random_with_recommendations.h",
"source/fuzz/pass_management/repeated_pass_manager_simple.cpp",
"source/fuzz/pass_management/repeated_pass_manager_simple.h",
"source/fuzz/pass_management/repeated_pass_recommender.cpp",
"source/fuzz/pass_management/repeated_pass_recommender.h",
"source/fuzz/pass_management/repeated_pass_recommender_standard.cpp",
"source/fuzz/pass_management/repeated_pass_recommender_standard.h",
"source/fuzz/protobufs/spirvfuzz_protobufs.h",
"source/fuzz/pseudo_random_generator.cpp",
"source/fuzz/pseudo_random_generator.h",
"source/fuzz/random_generator.cpp",
"source/fuzz/random_generator.h",
"source/fuzz/replayer.cpp",
"source/fuzz/replayer.h",
"source/fuzz/shrinker.cpp",
"source/fuzz/shrinker.h",
"source/fuzz/transformation.cpp",
"source/fuzz/transformation.h",
"source/fuzz/transformation_access_chain.cpp",
"source/fuzz/transformation_access_chain.h",
"source/fuzz/transformation_add_bit_instruction_synonym.cpp",
"source/fuzz/transformation_add_bit_instruction_synonym.h",
"source/fuzz/transformation_add_constant_boolean.cpp",
"source/fuzz/transformation_add_constant_boolean.h",
"source/fuzz/transformation_add_constant_composite.cpp",
"source/fuzz/transformation_add_constant_composite.h",
"source/fuzz/transformation_add_constant_null.cpp",
"source/fuzz/transformation_add_constant_null.h",
"source/fuzz/transformation_add_constant_scalar.cpp",
"source/fuzz/transformation_add_constant_scalar.h",
"source/fuzz/transformation_add_copy_memory.cpp",
"source/fuzz/transformation_add_copy_memory.h",
"source/fuzz/transformation_add_dead_block.cpp",
"source/fuzz/transformation_add_dead_block.h",
"source/fuzz/transformation_add_dead_break.cpp",
"source/fuzz/transformation_add_dead_break.h",
"source/fuzz/transformation_add_dead_continue.cpp",
"source/fuzz/transformation_add_dead_continue.h",
"source/fuzz/transformation_add_early_terminator_wrapper.cpp",
"source/fuzz/transformation_add_early_terminator_wrapper.h",
"source/fuzz/transformation_add_function.cpp",
"source/fuzz/transformation_add_function.h",
"source/fuzz/transformation_add_global_undef.cpp",
"source/fuzz/transformation_add_global_undef.h",
"source/fuzz/transformation_add_global_variable.cpp",
"source/fuzz/transformation_add_global_variable.h",
"source/fuzz/transformation_add_image_sample_unused_components.cpp",
"source/fuzz/transformation_add_image_sample_unused_components.h",
"source/fuzz/transformation_add_local_variable.cpp",
"source/fuzz/transformation_add_local_variable.h",
"source/fuzz/transformation_add_loop_preheader.cpp",
"source/fuzz/transformation_add_loop_preheader.h",
"source/fuzz/transformation_add_loop_to_create_int_constant_synonym.cpp",
"source/fuzz/transformation_add_loop_to_create_int_constant_synonym.h",
"source/fuzz/transformation_add_no_contraction_decoration.cpp",
"source/fuzz/transformation_add_no_contraction_decoration.h",
"source/fuzz/transformation_add_opphi_synonym.cpp",
"source/fuzz/transformation_add_opphi_synonym.h",
"source/fuzz/transformation_add_parameter.cpp",
"source/fuzz/transformation_add_parameter.h",
"source/fuzz/transformation_add_relaxed_decoration.cpp",
"source/fuzz/transformation_add_relaxed_decoration.h",
"source/fuzz/transformation_add_spec_constant_op.cpp",
"source/fuzz/transformation_add_spec_constant_op.h",
"source/fuzz/transformation_add_synonym.cpp",
"source/fuzz/transformation_add_synonym.h",
"source/fuzz/transformation_add_type_array.cpp",
"source/fuzz/transformation_add_type_array.h",
"source/fuzz/transformation_add_type_boolean.cpp",
"source/fuzz/transformation_add_type_boolean.h",
"source/fuzz/transformation_add_type_float.cpp",
"source/fuzz/transformation_add_type_float.h",
"source/fuzz/transformation_add_type_function.cpp",
"source/fuzz/transformation_add_type_function.h",
"source/fuzz/transformation_add_type_int.cpp",
"source/fuzz/transformation_add_type_int.h",
"source/fuzz/transformation_add_type_matrix.cpp",
"source/fuzz/transformation_add_type_matrix.h",
"source/fuzz/transformation_add_type_pointer.cpp",
"source/fuzz/transformation_add_type_pointer.h",
"source/fuzz/transformation_add_type_struct.cpp",
"source/fuzz/transformation_add_type_struct.h",
"source/fuzz/transformation_add_type_vector.cpp",
"source/fuzz/transformation_add_type_vector.h",
"source/fuzz/transformation_adjust_branch_weights.cpp",
"source/fuzz/transformation_adjust_branch_weights.h",
"source/fuzz/transformation_composite_construct.cpp",
"source/fuzz/transformation_composite_construct.h",
"source/fuzz/transformation_composite_extract.cpp",
"source/fuzz/transformation_composite_extract.h",
"source/fuzz/transformation_composite_insert.cpp",
"source/fuzz/transformation_composite_insert.h",
"source/fuzz/transformation_compute_data_synonym_fact_closure.cpp",
"source/fuzz/transformation_compute_data_synonym_fact_closure.h",
"source/fuzz/transformation_context.cpp",
"source/fuzz/transformation_context.h",
"source/fuzz/transformation_duplicate_region_with_selection.cpp",
"source/fuzz/transformation_duplicate_region_with_selection.h",
"source/fuzz/transformation_equation_instruction.cpp",
"source/fuzz/transformation_equation_instruction.h",
"source/fuzz/transformation_expand_vector_reduction.cpp",
"source/fuzz/transformation_expand_vector_reduction.h",
"source/fuzz/transformation_flatten_conditional_branch.cpp",
"source/fuzz/transformation_flatten_conditional_branch.h",
"source/fuzz/transformation_function_call.cpp",
"source/fuzz/transformation_function_call.h",
"source/fuzz/transformation_inline_function.cpp",
"source/fuzz/transformation_inline_function.h",
"source/fuzz/transformation_invert_comparison_operator.cpp",
"source/fuzz/transformation_invert_comparison_operator.h",
"source/fuzz/transformation_load.cpp",
"source/fuzz/transformation_load.h",
"source/fuzz/transformation_make_vector_operation_dynamic.cpp",
"source/fuzz/transformation_make_vector_operation_dynamic.h",
"source/fuzz/transformation_merge_blocks.cpp",
"source/fuzz/transformation_merge_blocks.h",
"source/fuzz/transformation_merge_function_returns.cpp",
"source/fuzz/transformation_merge_function_returns.h",
"source/fuzz/transformation_move_block_down.cpp",
"source/fuzz/transformation_move_block_down.h",
"source/fuzz/transformation_move_instruction_down.cpp",
"source/fuzz/transformation_move_instruction_down.h",
"source/fuzz/transformation_mutate_pointer.cpp",
"source/fuzz/transformation_mutate_pointer.h",
"source/fuzz/transformation_outline_function.cpp",
"source/fuzz/transformation_outline_function.h",
"source/fuzz/transformation_permute_function_parameters.cpp",
"source/fuzz/transformation_permute_function_parameters.h",
"source/fuzz/transformation_permute_phi_operands.cpp",
"source/fuzz/transformation_permute_phi_operands.h",
"source/fuzz/transformation_propagate_instruction_down.cpp",
"source/fuzz/transformation_propagate_instruction_down.h",
"source/fuzz/transformation_propagate_instruction_up.cpp",
"source/fuzz/transformation_propagate_instruction_up.h",
"source/fuzz/transformation_push_id_through_variable.cpp",
"source/fuzz/transformation_push_id_through_variable.h",
"source/fuzz/transformation_record_synonymous_constants.cpp",
"source/fuzz/transformation_record_synonymous_constants.h",
"source/fuzz/transformation_replace_add_sub_mul_with_carrying_extended.cpp",
"source/fuzz/transformation_replace_add_sub_mul_with_carrying_extended.h",
"source/fuzz/transformation_replace_boolean_constant_with_constant_binary.cpp",
"source/fuzz/transformation_replace_boolean_constant_with_constant_binary.h",
"source/fuzz/transformation_replace_branch_from_dead_block_with_exit.cpp",
"source/fuzz/transformation_replace_branch_from_dead_block_with_exit.h",
"source/fuzz/transformation_replace_constant_with_uniform.cpp",
"source/fuzz/transformation_replace_constant_with_uniform.h",
"source/fuzz/transformation_replace_copy_memory_with_load_store.cpp",
"source/fuzz/transformation_replace_copy_memory_with_load_store.h",
"source/fuzz/transformation_replace_copy_object_with_store_load.cpp",
"source/fuzz/transformation_replace_copy_object_with_store_load.h",
"source/fuzz/transformation_replace_id_with_synonym.cpp",
"source/fuzz/transformation_replace_id_with_synonym.h",
"source/fuzz/transformation_replace_irrelevant_id.cpp",
"source/fuzz/transformation_replace_irrelevant_id.h",
"source/fuzz/transformation_replace_linear_algebra_instruction.cpp",
"source/fuzz/transformation_replace_linear_algebra_instruction.h",
"source/fuzz/transformation_replace_load_store_with_copy_memory.cpp",
"source/fuzz/transformation_replace_load_store_with_copy_memory.h",
"source/fuzz/transformation_replace_opphi_id_from_dead_predecessor.cpp",
"source/fuzz/transformation_replace_opphi_id_from_dead_predecessor.h",
"source/fuzz/transformation_replace_opselect_with_conditional_branch.cpp",
"source/fuzz/transformation_replace_opselect_with_conditional_branch.h",
"source/fuzz/transformation_replace_parameter_with_global.cpp",
"source/fuzz/transformation_replace_parameter_with_global.h",
"source/fuzz/transformation_replace_params_with_struct.cpp",
"source/fuzz/transformation_replace_params_with_struct.h",
"source/fuzz/transformation_set_function_control.cpp",
"source/fuzz/transformation_set_function_control.h",
"source/fuzz/transformation_set_loop_control.cpp",
"source/fuzz/transformation_set_loop_control.h",
"source/fuzz/transformation_set_memory_operands_mask.cpp",
"source/fuzz/transformation_set_memory_operands_mask.h",
"source/fuzz/transformation_set_selection_control.cpp",
"source/fuzz/transformation_set_selection_control.h",
"source/fuzz/transformation_split_block.cpp",
"source/fuzz/transformation_split_block.h",
"source/fuzz/transformation_store.cpp",
"source/fuzz/transformation_store.h",
"source/fuzz/transformation_swap_commutable_operands.cpp",
"source/fuzz/transformation_swap_commutable_operands.h",
"source/fuzz/transformation_swap_conditional_branch_operands.cpp",
"source/fuzz/transformation_swap_conditional_branch_operands.h",
"source/fuzz/transformation_swap_function_variables.cpp",
"source/fuzz/transformation_swap_function_variables.h",
"source/fuzz/transformation_swap_two_functions.cpp",
"source/fuzz/transformation_swap_two_functions.h",
"source/fuzz/transformation_toggle_access_chain_instruction.cpp",
"source/fuzz/transformation_toggle_access_chain_instruction.h",
"source/fuzz/transformation_vector_shuffle.cpp",
"source/fuzz/transformation_vector_shuffle.h",
"source/fuzz/transformation_wrap_early_terminator_in_function.cpp",
"source/fuzz/transformation_wrap_early_terminator_in_function.h",
"source/fuzz/transformation_wrap_region_in_selection.cpp",
"source/fuzz/transformation_wrap_region_in_selection.h",
"source/fuzz/uniform_buffer_element_descriptor.cpp",
"source/fuzz/uniform_buffer_element_descriptor.h",
]
deps = [
"//third_party/protobuf:protobuf_full",
":spvtools_fuzz_proto",
":spvtools",
":spvtools_opt",
]
public_deps = [ ":spvtools_headers" ]
if (build_with_chromium) {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
}
configs += [ ":spvtools_internal_config" ]
}
group("SPIRV-Tools") {
public_deps = [
":spvtools",
@ -1063,7 +1477,25 @@ executable("spirv-link") {
}
if (!is_ios && !spirv_is_winuwp) {
# iOS and UWP do not allow std::system calls which spirv-reduce requires
# iOS and UWP do not allow std::system calls which spirv-fuzz and
# spirv-reduce require
executable("spirv-fuzz") {
sources = [ "tools/fuzz/fuzz.cpp" ]
deps = [
"//third_party/protobuf:protobuf_full",
":spvtools",
":spvtools_fuzz",
":spvtools_reduce",
":spvtools_opt",
":spvtools_software_version",
":spvtools_util_cli_consumer",
":spvtools_val",
]
configs += [ ":spvtools_internal_config" ]
}
executable("spirv-reduce") {
sources = [ "tools/reduce/reduce.cpp" ]
deps = [
@ -1088,6 +1520,9 @@ group("all_spirv_tools") {
":spirv-val",
]
if (!is_ios && !spirv_is_winuwp) {
deps += [ ":spirv-reduce" ]
deps += [
":spirv-fuzz",
":spirv-reduce",
]
}
}

View File

@ -348,7 +348,7 @@ option, like so:
```sh
# In <spirv-dir> (the SPIRV-Tools repo root):
git clone --depth=1 --branch v3.13.0 https://github.com/protocolbuffers/protobuf external/protobuf
git clone --depth=1 --branch v3.13.0.1 https://github.com/protocolbuffers/protobuf external/protobuf
# In your build directory:
cmake [-G <platform-generator>] <spirv-dir> -DSPIRV_BUILD_FUZZER=ON

View File

@ -51,7 +51,7 @@ clone_if_missing https://github.com/google/googletest external/googlete
pushd external/googletest; git reset --hard 1fb1bb23bb8418dc73a5a9a82bbed31dc610fec7; popd
clone_if_missing https://github.com/google/effcee external/effcee --depth=1
clone_if_missing https://github.com/google/re2 external/re2 --depth=1
clone_if_missing https://github.com/protocolbuffers/protobuf external/protobuf --branch v3.13.0
clone_if_missing https://github.com/protocolbuffers/protobuf external/protobuf --branch v3.13.0.1
if [ $TOOL = "cmake" ]; then
using cmake-3.17.2

View File

@ -36,7 +36,7 @@ git clone https://github.com/google/googletest external/googletest
cd external && cd googletest && git reset --hard 1fb1bb23bb8418dc73a5a9a82bbed31dc610fec7 && cd .. && cd ..
git clone --depth=1 https://github.com/google/effcee external/effcee
git clone --depth=1 https://github.com/google/re2 external/re2
git clone --depth=1 --branch v3.13.0 https://github.com/protocolbuffers/protobuf external/protobuf
git clone --depth=1 --branch v3.13.0.1 https://github.com/protocolbuffers/protobuf external/protobuf
mkdir build && cd $SRC/build

View File

@ -30,7 +30,7 @@ git clone https://github.com/google/googletest external/googletest
cd external && cd googletest && git reset --hard 1fb1bb23bb8418dc73a5a9a82bbed31dc610fec7 && cd .. && cd ..
git clone --depth=1 https://github.com/google/effcee external/effcee
git clone --depth=1 https://github.com/google/re2 external/re2
git clone --depth=1 --branch v3.13.0 https://github.com/protocolbuffers/protobuf external/protobuf
git clone --depth=1 --branch v3.13.0.1 https://github.com/protocolbuffers/protobuf external/protobuf
:: #########################################
:: set up msvc build env

View File

@ -673,6 +673,19 @@ void DumpTransformationsBinary(
transformations_file.close();
}
// The Chromium project applies the following patch to the protobuf library:
//
// source.chromium.org/chromium/chromium/src/+/main:third_party/protobuf/patches/0003-remove-static-initializers.patch
//
// This affects how Status objects must be constructed. This method provides a
// convenient way to get the OK status that works both with and without the
// patch. With the patch OK is a StatusPod, from which a Status can be
// constructed. Without the patch, OK is already a Status, and we harmlessly
// copy-construct the result from it.
google::protobuf::util::Status GetProtobufOkStatus() {
return google::protobuf::util::Status(google::protobuf::util::Status::OK);
}
// Dumps |transformations| to file |filename| in JSON format. Useful for
// interactive debugging.
void DumpTransformationsJson(
@ -683,7 +696,7 @@ void DumpTransformationsJson(
json_options.add_whitespace = true;
auto json_generation_status = google::protobuf::util::MessageToJsonString(
transformations, &json_string, json_options);
if (json_generation_status == google::protobuf::util::Status::OK) {
if (json_generation_status == GetProtobufOkStatus()) {
std::ofstream transformations_json_file(filename);
transformations_json_file << json_string;
transformations_json_file.close();
@ -734,9 +747,8 @@ int main(int argc, const char** argv) {
std::string facts_json_string((std::istreambuf_iterator<char>(facts_input)),
std::istreambuf_iterator<char>());
facts_input.close();
if (google::protobuf::util::Status::OK !=
google::protobuf::util::JsonStringToMessage(facts_json_string,
&initial_facts)) {
if (GetProtobufOkStatus() != google::protobuf::util::JsonStringToMessage(
facts_json_string, &initial_facts)) {
spvtools::Error(FuzzDiagnostic, nullptr, {}, "Error reading facts data");
return 1;
}
@ -816,7 +828,7 @@ int main(int argc, const char** argv) {
json_options.add_whitespace = true;
auto json_generation_status = google::protobuf::util::MessageToJsonString(
transformations_applied, &json_string, json_options);
if (json_generation_status != google::protobuf::util::Status::OK) {
if (json_generation_status != GetProtobufOkStatus()) {
spvtools::Error(FuzzDiagnostic, nullptr, {},
"Error writing out transformations in JSON format");
return 1;