Debian Codegraph @

third_party/spirv-tools/source/fuzz/CMakeLists.txt

raw
1 # Copyright (c) 2019 Google LLC
2
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 if(SPIRV_BUILD_FUZZER)
16
17 file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/protobufs)
18
19 set(PROTOBUF_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/protobufs/spvtoolsfuzz.proto)
20
21 set(
22 SPIRV_FUZZ_PROTOC_COMMAND
23 "protobuf::protoc"
24 CACHE
25 STRING
26 "The command to invoke the protobuf compiler (protoc). By default it is the protobufs::protoc CMake target. It should be overridden when cross-compiling, such as for Android.")
27
28 add_custom_command(
29 OUTPUT protobufs/spvtoolsfuzz.pb.cc protobufs/spvtoolsfuzz.pb.h
30 COMMAND "${SPIRV_FUZZ_PROTOC_COMMAND}"
31 -I=${CMAKE_CURRENT_SOURCE_DIR}/protobufs
32 --cpp_out=protobufs
33 ${PROTOBUF_SOURCE}
34 DEPENDS ${PROTOBUF_SOURCE}
35 COMMENT "Generate protobuf sources from proto definition file."
36 )
37
38 set(SPIRV_TOOLS_FUZZ_SOURCES
39 added_function_reducer.h
40 call_graph.h
41 comparator_deep_blocks_first.h
42 counter_overflow_id_source.h
43 data_descriptor.h
44 equivalence_relation.h
45 fact_manager/constant_uniform_facts.h
46 fact_manager/data_synonym_and_id_equation_facts.h
47 fact_manager/dead_block_facts.h
48 fact_manager/fact_manager.h
49 fact_manager/irrelevant_value_facts.h
50 fact_manager/livesafe_function_facts.h
51 force_render_red.h
52 fuzzer.h
53 fuzzer_context.h
54 fuzzer_pass.h
55 fuzzer_pass_add_access_chains.h
56 fuzzer_pass_add_bit_instruction_synonyms.h
57 fuzzer_pass_add_composite_extract.h
58 fuzzer_pass_add_composite_inserts.h
59 fuzzer_pass_add_composite_types.h
60 fuzzer_pass_add_copy_memory.h
61 fuzzer_pass_add_dead_blocks.h
62 fuzzer_pass_add_dead_breaks.h
63 fuzzer_pass_add_dead_continues.h
64 fuzzer_pass_add_equation_instructions.h
65 fuzzer_pass_add_function_calls.h
66 fuzzer_pass_add_global_variables.h
67 fuzzer_pass_add_image_sample_unused_components.h
68 fuzzer_pass_add_loads.h
69 fuzzer_pass_add_local_variables.h
70 fuzzer_pass_add_loop_preheaders.h
71 fuzzer_pass_add_loops_to_create_int_constant_synonyms.h
72 fuzzer_pass_add_no_contraction_decorations.h
73 fuzzer_pass_add_opphi_synonyms.h
74 fuzzer_pass_add_parameters.h
75 fuzzer_pass_add_relaxed_decorations.h
76 fuzzer_pass_add_stores.h
77 fuzzer_pass_add_synonyms.h
78 fuzzer_pass_add_vector_shuffle_instructions.h
79 fuzzer_pass_adjust_branch_weights.h
80 fuzzer_pass_adjust_function_controls.h
81 fuzzer_pass_adjust_loop_controls.h
82 fuzzer_pass_adjust_memory_operands_masks.h
83 fuzzer_pass_adjust_selection_controls.h
84 fuzzer_pass_apply_id_synonyms.h
85 fuzzer_pass_construct_composites.h
86 fuzzer_pass_copy_objects.h
87 fuzzer_pass_donate_modules.h
88 fuzzer_pass_duplicate_regions_with_selections.h
89 fuzzer_pass_expand_vector_reductions.h
90 fuzzer_pass_flatten_conditional_branches.h
91 fuzzer_pass_inline_functions.h
92 fuzzer_pass_invert_comparison_operators.h
93 fuzzer_pass_interchange_signedness_of_integer_operands.h
94 fuzzer_pass_interchange_zero_like_constants.h
95 fuzzer_pass_make_vector_operations_dynamic.h
96 fuzzer_pass_merge_blocks.h
97 fuzzer_pass_merge_function_returns.h
98 fuzzer_pass_mutate_pointers.h
99 fuzzer_pass_obfuscate_constants.h
100 fuzzer_pass_outline_functions.h
101 fuzzer_pass_permute_blocks.h
102 fuzzer_pass_permute_function_parameters.h
103 fuzzer_pass_permute_instructions.h
104 fuzzer_pass_permute_phi_operands.h
105 fuzzer_pass_propagate_instructions_down.h
106 fuzzer_pass_propagate_instructions_up.h
107 fuzzer_pass_push_ids_through_variables.h
108 fuzzer_pass_replace_adds_subs_muls_with_carrying_extended.h
109 fuzzer_pass_replace_branches_from_dead_blocks_with_exits.h
110 fuzzer_pass_replace_copy_memories_with_loads_stores.h
111 fuzzer_pass_replace_copy_objects_with_stores_loads.h
112 fuzzer_pass_replace_irrelevant_ids.h
113 fuzzer_pass_replace_linear_algebra_instructions.h
114 fuzzer_pass_replace_loads_stores_with_copy_memories.h
115 fuzzer_pass_replace_opphi_ids_from_dead_predecessors.h
116 fuzzer_pass_replace_opselects_with_conditional_branches.h
117 fuzzer_pass_replace_parameter_with_global.h
118 fuzzer_pass_replace_params_with_struct.h
119 fuzzer_pass_split_blocks.h
120 fuzzer_pass_swap_commutable_operands.h
121 fuzzer_pass_swap_conditional_branch_operands.h
122 fuzzer_pass_toggle_access_chain_instruction.h
123 fuzzer_pass_wrap_regions_in_selections.h
124 fuzzer_util.h
125 id_use_descriptor.h
126 instruction_descriptor.h
127 instruction_message.h
128 overflow_id_source.h
129 pass_management/repeated_pass_instances.h
130 pass_management/repeated_pass_manager.h
131 pass_management/repeated_pass_manager_looped_with_recommendations.h
132 pass_management/repeated_pass_manager_random_with_recommendations.h
133 pass_management/repeated_pass_manager_simple.h
134 pass_management/repeated_pass_recommender.h
135 pass_management/repeated_pass_recommender_standard.h
136 protobufs/spirvfuzz_protobufs.h
137 pseudo_random_generator.h
138 random_generator.h
139 replayer.h
140 shrinker.h
141 transformation.h
142 transformation_access_chain.h
143 transformation_add_bit_instruction_synonym.h
144 transformation_add_constant_boolean.h
145 transformation_add_constant_composite.h
146 transformation_add_constant_null.h
147 transformation_add_constant_scalar.h
148 transformation_add_copy_memory.h
149 transformation_add_dead_block.h
150 transformation_add_dead_break.h
151 transformation_add_dead_continue.h
152 transformation_add_early_terminator_wrapper.h
153 transformation_add_function.h
154 transformation_add_global_undef.h
155 transformation_add_global_variable.h
156 transformation_add_image_sample_unused_components.h
157 transformation_add_local_variable.h
158 transformation_add_loop_preheader.h
159 transformation_add_loop_to_create_int_constant_synonym.h
160 transformation_add_no_contraction_decoration.h
161 transformation_add_opphi_synonym.h
162 transformation_add_parameter.h
163 transformation_add_relaxed_decoration.h
164 transformation_add_spec_constant_op.h
165 transformation_add_synonym.h
166 transformation_add_type_array.h
167 transformation_add_type_boolean.h
168 transformation_add_type_float.h
169 transformation_add_type_function.h
170 transformation_add_type_int.h
171 transformation_add_type_matrix.h
172 transformation_add_type_pointer.h
173 transformation_add_type_struct.h
174 transformation_add_type_vector.h
175 transformation_adjust_branch_weights.h
176 transformation_composite_construct.h
177 transformation_composite_extract.h
178 transformation_composite_insert.h
179 transformation_compute_data_synonym_fact_closure.h
180 transformation_context.h
181 transformation_duplicate_region_with_selection.h
182 transformation_equation_instruction.h
183 transformation_expand_vector_reduction.h
184 transformation_flatten_conditional_branch.h
185 transformation_function_call.h
186 transformation_inline_function.h
187 transformation_invert_comparison_operator.h
188 transformation_load.h
189 transformation_make_vector_operation_dynamic.h
190 transformation_merge_blocks.h
191 transformation_merge_function_returns.h
192 transformation_move_block_down.h
193 transformation_move_instruction_down.h
194 transformation_mutate_pointer.h
195 transformation_outline_function.h
196 transformation_permute_function_parameters.h
197 transformation_permute_phi_operands.h
198 transformation_propagate_instruction_down.h
199 transformation_propagate_instruction_up.h
200 transformation_push_id_through_variable.h
201 transformation_record_synonymous_constants.h
202 transformation_replace_add_sub_mul_with_carrying_extended.h
203 transformation_replace_boolean_constant_with_constant_binary.h
204 transformation_replace_branch_from_dead_block_with_exit.h
205 transformation_replace_constant_with_uniform.h
206 transformation_replace_copy_memory_with_load_store.h
207 transformation_replace_copy_object_with_store_load.h
208 transformation_replace_id_with_synonym.h
209 transformation_replace_irrelevant_id.h
210 transformation_replace_linear_algebra_instruction.h
211 transformation_replace_load_store_with_copy_memory.h
212 transformation_replace_opphi_id_from_dead_predecessor.h
213 transformation_replace_opselect_with_conditional_branch.h
214 transformation_replace_parameter_with_global.h
215 transformation_replace_params_with_struct.h
216 transformation_set_function_control.h
217 transformation_set_loop_control.h
218 transformation_set_memory_operands_mask.h
219 transformation_set_selection_control.h
220 transformation_split_block.h
221 transformation_store.h
222 transformation_swap_commutable_operands.h
223 transformation_swap_conditional_branch_operands.h
224 transformation_toggle_access_chain_instruction.h
225 transformation_vector_shuffle.h
226 transformation_wrap_early_terminator_in_function.h
227 transformation_wrap_region_in_selection.h
228 uniform_buffer_element_descriptor.h
229 ${CMAKE_CURRENT_BINARY_DIR}/protobufs/spvtoolsfuzz.pb.h
230
231 added_function_reducer.cpp
232 call_graph.cpp
233 counter_overflow_id_source.cpp
234 data_descriptor.cpp
235 fact_manager/constant_uniform_facts.cpp
236 fact_manager/data_synonym_and_id_equation_facts.cpp
237 fact_manager/dead_block_facts.cpp
238 fact_manager/fact_manager.cpp
239 fact_manager/irrelevant_value_facts.cpp
240 fact_manager/livesafe_function_facts.cpp
241 force_render_red.cpp
242 fuzzer.cpp
243 fuzzer_context.cpp
244 fuzzer_pass.cpp
245 fuzzer_pass_add_access_chains.cpp
246 fuzzer_pass_add_bit_instruction_synonyms.cpp
247 fuzzer_pass_add_composite_extract.cpp
248 fuzzer_pass_add_composite_inserts.cpp
249 fuzzer_pass_add_composite_types.cpp
250 fuzzer_pass_add_copy_memory.cpp
251 fuzzer_pass_add_dead_blocks.cpp
252 fuzzer_pass_add_dead_breaks.cpp
253 fuzzer_pass_add_dead_continues.cpp
254 fuzzer_pass_add_equation_instructions.cpp
255 fuzzer_pass_add_function_calls.cpp
256 fuzzer_pass_add_global_variables.cpp
257 fuzzer_pass_add_image_sample_unused_components.cpp
258 fuzzer_pass_add_loads.cpp
259 fuzzer_pass_add_local_variables.cpp
260 fuzzer_pass_add_loop_preheaders.cpp
261 fuzzer_pass_add_loops_to_create_int_constant_synonyms.cpp
262 fuzzer_pass_add_no_contraction_decorations.cpp
263 fuzzer_pass_add_opphi_synonyms.cpp
264 fuzzer_pass_add_parameters.cpp
265 fuzzer_pass_add_relaxed_decorations.cpp
266 fuzzer_pass_add_stores.cpp
267 fuzzer_pass_add_synonyms.cpp
268 fuzzer_pass_add_vector_shuffle_instructions.cpp
269 fuzzer_pass_adjust_branch_weights.cpp
270 fuzzer_pass_adjust_function_controls.cpp
271 fuzzer_pass_adjust_loop_controls.cpp
272 fuzzer_pass_adjust_memory_operands_masks.cpp
273 fuzzer_pass_adjust_selection_controls.cpp
274 fuzzer_pass_apply_id_synonyms.cpp
275 fuzzer_pass_construct_composites.cpp
276 fuzzer_pass_copy_objects.cpp
277 fuzzer_pass_donate_modules.cpp
278 fuzzer_pass_duplicate_regions_with_selections.cpp
279 fuzzer_pass_expand_vector_reductions.cpp
280 fuzzer_pass_flatten_conditional_branches.cpp
281 fuzzer_pass_inline_functions.cpp
282 fuzzer_pass_invert_comparison_operators.cpp
283 fuzzer_pass_interchange_signedness_of_integer_operands.cpp
284 fuzzer_pass_interchange_zero_like_constants.cpp
285 fuzzer_pass_make_vector_operations_dynamic.cpp
286 fuzzer_pass_merge_blocks.cpp
287 fuzzer_pass_merge_function_returns.cpp
288 fuzzer_pass_mutate_pointers.cpp
289 fuzzer_pass_obfuscate_constants.cpp
290 fuzzer_pass_outline_functions.cpp
291 fuzzer_pass_permute_blocks.cpp
292 fuzzer_pass_permute_function_parameters.cpp
293 fuzzer_pass_permute_instructions.cpp
294 fuzzer_pass_permute_phi_operands.cpp
295 fuzzer_pass_propagate_instructions_down.cpp
296 fuzzer_pass_propagate_instructions_up.cpp
297 fuzzer_pass_push_ids_through_variables.cpp
298 fuzzer_pass_replace_adds_subs_muls_with_carrying_extended.cpp
299 fuzzer_pass_replace_branches_from_dead_blocks_with_exits.cpp
300 fuzzer_pass_replace_copy_memories_with_loads_stores.cpp
301 fuzzer_pass_replace_copy_objects_with_stores_loads.cpp
302 fuzzer_pass_replace_irrelevant_ids.cpp
303 fuzzer_pass_replace_linear_algebra_instructions.cpp
304 fuzzer_pass_replace_loads_stores_with_copy_memories.cpp
305 fuzzer_pass_replace_opphi_ids_from_dead_predecessors.cpp
306 fuzzer_pass_replace_opselects_with_conditional_branches.cpp
307 fuzzer_pass_replace_parameter_with_global.cpp
308 fuzzer_pass_replace_params_with_struct.cpp
309 fuzzer_pass_split_blocks.cpp
310 fuzzer_pass_swap_commutable_operands.cpp
311 fuzzer_pass_swap_conditional_branch_operands.cpp
312 fuzzer_pass_toggle_access_chain_instruction.cpp
313 fuzzer_pass_wrap_regions_in_selections.cpp
314 fuzzer_util.cpp
315 id_use_descriptor.cpp
316 instruction_descriptor.cpp
317 instruction_message.cpp
318 overflow_id_source.cpp
319 pass_management/repeated_pass_manager.cpp
320 pass_management/repeated_pass_manager_looped_with_recommendations.cpp
321 pass_management/repeated_pass_manager_random_with_recommendations.cpp
322 pass_management/repeated_pass_manager_simple.cpp
323 pass_management/repeated_pass_recommender.cpp
324 pass_management/repeated_pass_recommender_standard.cpp
325 pseudo_random_generator.cpp
326 random_generator.cpp
327 replayer.cpp
328 shrinker.cpp
329 transformation.cpp
330 transformation_access_chain.cpp
331 transformation_add_bit_instruction_synonym.cpp
332 transformation_add_constant_boolean.cpp
333 transformation_add_constant_composite.cpp
334 transformation_add_constant_null.cpp
335 transformation_add_constant_scalar.cpp
336 transformation_add_copy_memory.cpp
337 transformation_add_dead_block.cpp
338 transformation_add_dead_break.cpp
339 transformation_add_dead_continue.cpp
340 transformation_add_early_terminator_wrapper.cpp
341 transformation_add_function.cpp
342 transformation_add_global_undef.cpp
343 transformation_add_global_variable.cpp
344 transformation_add_image_sample_unused_components.cpp
345 transformation_add_local_variable.cpp
346 transformation_add_loop_preheader.cpp
347 transformation_add_loop_to_create_int_constant_synonym.cpp
348 transformation_add_no_contraction_decoration.cpp
349 transformation_add_opphi_synonym.cpp
350 transformation_add_parameter.cpp
351 transformation_add_relaxed_decoration.cpp
352 transformation_add_spec_constant_op.cpp
353 transformation_add_synonym.cpp
354 transformation_add_type_array.cpp
355 transformation_add_type_boolean.cpp
356 transformation_add_type_float.cpp
357 transformation_add_type_function.cpp
358 transformation_add_type_int.cpp
359 transformation_add_type_matrix.cpp
360 transformation_add_type_pointer.cpp
361 transformation_add_type_struct.cpp
362 transformation_add_type_vector.cpp
363 transformation_adjust_branch_weights.cpp
364 transformation_composite_construct.cpp
365 transformation_composite_extract.cpp
366 transformation_composite_insert.cpp
367 transformation_compute_data_synonym_fact_closure.cpp
368 transformation_context.cpp
369 transformation_duplicate_region_with_selection.cpp
370 transformation_equation_instruction.cpp
371 transformation_expand_vector_reduction.cpp
372 transformation_flatten_conditional_branch.cpp
373 transformation_function_call.cpp
374 transformation_inline_function.cpp
375 transformation_invert_comparison_operator.cpp
376 transformation_load.cpp
377 transformation_make_vector_operation_dynamic.cpp
378 transformation_merge_blocks.cpp
379 transformation_merge_function_returns.cpp
380 transformation_move_block_down.cpp
381 transformation_move_instruction_down.cpp
382 transformation_mutate_pointer.cpp
383 transformation_outline_function.cpp
384 transformation_permute_function_parameters.cpp
385 transformation_permute_phi_operands.cpp
386 transformation_propagate_instruction_down.cpp
387 transformation_propagate_instruction_up.cpp
388 transformation_push_id_through_variable.cpp
389 transformation_record_synonymous_constants.cpp
390 transformation_replace_add_sub_mul_with_carrying_extended.cpp
391 transformation_replace_boolean_constant_with_constant_binary.cpp
392 transformation_replace_branch_from_dead_block_with_exit.cpp
393 transformation_replace_constant_with_uniform.cpp
394 transformation_replace_copy_memory_with_load_store.cpp
395 transformation_replace_copy_object_with_store_load.cpp
396 transformation_replace_id_with_synonym.cpp
397 transformation_replace_irrelevant_id.cpp
398 transformation_replace_linear_algebra_instruction.cpp
399 transformation_replace_load_store_with_copy_memory.cpp
400 transformation_replace_opphi_id_from_dead_predecessor.cpp
401 transformation_replace_opselect_with_conditional_branch.cpp
402 transformation_replace_parameter_with_global.cpp
403 transformation_replace_params_with_struct.cpp
404 transformation_set_function_control.cpp
405 transformation_set_loop_control.cpp
406 transformation_set_memory_operands_mask.cpp
407 transformation_set_selection_control.cpp
408 transformation_split_block.cpp
409 transformation_store.cpp
410 transformation_swap_commutable_operands.cpp
411 transformation_swap_conditional_branch_operands.cpp
412 transformation_toggle_access_chain_instruction.cpp
413 transformation_vector_shuffle.cpp
414 transformation_wrap_early_terminator_in_function.cpp
415 transformation_wrap_region_in_selection.cpp
416 uniform_buffer_element_descriptor.cpp
417 ${CMAKE_CURRENT_BINARY_DIR}/protobufs/spvtoolsfuzz.pb.cc
418 )
419
420 if(MSVC AND (NOT ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")))
421 # Enable parallel builds across four cores for this lib
422 add_definitions(/MP4)
423 endif()
424
425 spvtools_pch(SPIRV_TOOLS_FUZZ_SOURCES pch_source_fuzz)
426
427 add_library(SPIRV-Tools-fuzz ${SPIRV_TOOLS_FUZZ_SOURCES})
428
429 spvtools_default_compile_options(SPIRV-Tools-fuzz)
430
431 # Compilation of the auto-generated protobuf source file will yield warnings,
432 # which we have no control over and thus wish to ignore.
433 if(${COMPILER_IS_LIKE_GNU})
434 set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/protobufs/spvtoolsfuzz.pb.cc PROPERTIES COMPILE_FLAGS -w)
435 endif()
436 if(MSVC)
437 set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/protobufs/spvtoolsfuzz.pb.cc PROPERTIES COMPILE_FLAGS /w)
438 endif()
439
440 target_include_directories(SPIRV-Tools-fuzz
441 PUBLIC
442 $<BUILD_INTERFACE:${spirv-tools_SOURCE_DIR}/include>
443 $<BUILD_INTERFACE:${SPIRV_HEADER_INCLUDE_DIR}>
444 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
445 PRIVATE ${spirv-tools_BINARY_DIR}
446 PRIVATE ${CMAKE_BINARY_DIR})
447
448 # The fuzzer reuses a lot of functionality from the SPIRV-Tools library.
449 target_link_libraries(SPIRV-Tools-fuzz
450 PUBLIC ${SPIRV_TOOLS_FULL_VISIBILITY}
451 PUBLIC SPIRV-Tools-opt
452 PUBLIC SPIRV-Tools-reduce
453 PUBLIC protobuf::libprotobuf)
454
455 set_property(TARGET SPIRV-Tools-fuzz PROPERTY FOLDER "SPIRV-Tools libraries")
456 spvtools_check_symbol_exports(SPIRV-Tools-fuzz)
457
458 if(ENABLE_SPIRV_TOOLS_INSTALL)
459 install(TARGETS SPIRV-Tools-fuzz EXPORT SPIRV-Tools-fuzzTargets
460 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
461 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
462 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
463 export(EXPORT SPIRV-Tools-fuzzTargets FILE SPIRV-Tools-fuzzTarget.cmake)
464
465 spvtools_config_package_dir(SPIRV-Tools-fuzz PACKAGE_DIR)
466 install(EXPORT SPIRV-Tools-fuzzTargets FILE SPIRV-Tools-fuzzTarget.cmake
467 DESTINATION ${PACKAGE_DIR})
468
469 spvtools_generate_config_file(SPIRV-Tools-fuzz)
470 install(FILES ${CMAKE_BINARY_DIR}/SPIRV-Tools-fuzzConfig.cmake DESTINATION ${PACKAGE_DIR})
471 endif(ENABLE_SPIRV_TOOLS_INSTALL)
472
473 endif(SPIRV_BUILD_FUZZER)