forked from google/autofdo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
873 lines (794 loc) · 27.4 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 17)
set(ABSL_PROPAGATE_CXX_STD on)
project(autofdo)
if (NOT DEFINED BUILD_SHARED)
set(BUILD_SHARED FALSE)
endif()
if (NOT ${BUILD_SHARED})
set (Protobuf_USE_STATIC_LIBS TRUE)
endif()
function (execute_perf_protobuf)
find_package(Protobuf REQUIRED)
add_library(perf_proto
third_party/perf_data_converter/src/quipper/perf_data.proto
third_party/perf_data_converter/src/quipper/perf_parser_options.proto
third_party/perf_data_converter/src/quipper/perf_stat.proto)
protobuf_generate(TARGET perf_proto LANGUAGE cpp)
target_link_libraries(perf_proto PUBLIC protobuf::libprotobuf)
endfunction()
function (build_gcov)
add_subdirectory(third_party/abseil)
add_subdirectory(third_party/glog)
add_subdirectory(third_party/googletest)
add_custom_target(exclude_extlib_tests ALL
COMMAND rm -f ${gtest_BINARY_DIR}/CTestTestfile.cmake
COMMAND rm -f ${gmock_BINARY_DIR}/CTestTestfile.cmake
COMMAND rm -f ${googletest-distribution_BINARY_DIR}/CTestTestfile.cmake
COMMAND rm -f ${glog_BINARY_DIR}/CTestTestfile.cmake
COMMAND rm -f ${absl_BINARY_DIR}/CTestTestfile.cmake)
include_directories(${CMAKE_HOME_DIRECTORY}
third_party/glog/src
third_party/abseil
third_party/perf_data_converter/src
third_party/perf_data_converter/src/quipper
third_party/googletest/googletest/include
third_party/googletest/googlemock/include
util
${PROJECT_BINARY_DIR}
${PROJECT_BINARY_DIR}/third_party/glog
${PROJECT_BINARY_DIR}/third_party/perf_data_converter/src/quipper)
find_library (LIBELF_LIBRARIES NAMES elf REQUIRED)
find_library (LIBCRYPTO_LIBRARIES NAMES crypto REQUIRED)
add_library(addr2line_lib OBJECT
legacy_addr2line.cc
util/symbolize/addr2line_inlinestack.cc
util/symbolize/bytereader.cc
util/symbolize/functioninfo.cc
util/symbolize/dwarf2reader.cc
util/symbolize/dwarf3ranges.cc
util/symbolize/elf_reader.cc
util/symbolize/index_helper.cc
)
add_library(create_gcov_lib OBJECT
create_gcov.cc
gcov.cc
instruction_map.cc
profile.cc
profile_creator.cc
profile_writer.cc
sample_reader.cc
symbol_map.cc
)
target_link_libraries(create_gcov_lib perf_proto)
add_library(quipper_perf OBJECT
third_party/perf_data_converter/src/quipper/address_mapper.cc
third_party/perf_data_converter/src/quipper/base/logging.cc
third_party/perf_data_converter/src/quipper/binary_data_utils.cc
third_party/perf_data_converter/src/quipper/binary_data_utils.cc
third_party/perf_data_converter/src/quipper/buffer_reader.cc
third_party/perf_data_converter/src/quipper/buffer_writer.cc
third_party/perf_data_converter/src/quipper/compat/log_level.cc
third_party/perf_data_converter/src/quipper/data_reader.cc
third_party/perf_data_converter/src/quipper/data_writer.cc
third_party/perf_data_converter/src/quipper/dso.cc
third_party/perf_data_converter/src/quipper/file_reader.cc
third_party/perf_data_converter/src/quipper/file_utils.cc
third_party/perf_data_converter/src/quipper/huge_page_deducer.cc
third_party/perf_data_converter/src/quipper/perf_buildid.cc
third_party/perf_data_converter/src/quipper/perf_data_utils.cc
third_party/perf_data_converter/src/quipper/perf_serializer.cc
third_party/perf_data_converter/src/quipper/perf_reader.cc
third_party/perf_data_converter/src/quipper/perf_parser.cc
third_party/perf_data_converter/src/quipper/sample_info_reader.cc
third_party/perf_data_converter/src/quipper/string_utils.cc)
target_include_directories(quipper_perf PRIVATE
third_party/abseil)
target_include_directories(quipper_perf BEFORE
PUBLIC
third_party/perf_data_converter/src
third_party/perf_data_converter/src/quipper)
target_link_libraries(quipper_perf
perf_proto ${Protobuf_LIBRARIES} ${LIBELF_LIBRARIES} ${LIBCRYPTO_LIBRARIES})
add_executable(create_gcov)
target_link_libraries(create_gcov
absl::flags
absl::flags_parse
create_gcov_lib
addr2line_lib
glog
quipper_perf
)
add_library(profile_merger_lib OBJECT
gcov.cc
instruction_map.cc
profile_merger.cc
profile.cc
profile_reader.cc
profile_writer.cc
symbol_map.cc
util/symbolize/elf_reader.cc
)
target_link_libraries(profile_merger_lib perf_proto)
add_executable(profile_merger)
target_link_libraries(profile_merger
absl::flags
absl::flags_parse
profile_merger_lib
glog
quipper_perf
)
add_library(dump_gcov_lib OBJECT
dump_gcov.cc
gcov.cc
instruction_map.cc
profile.cc
profile_reader.cc
symbol_map.cc
util/symbolize/elf_reader.cc)
target_link_libraries(dump_gcov_lib perf_proto)
add_executable(dump_gcov)
target_link_libraries(dump_gcov
absl::flags
absl::flags_parse
dump_gcov_lib
glog)
add_executable(addr2line_test addr2line_test.cc)
target_link_libraries(addr2line_test
absl::base
gtest
gtest_main
absl::flags
absl::flags_parse
addr2line_lib
glog
quipper_perf)
add_test(NAME addr2line_test COMMAND addr2line_test)
add_custom_command(PRE_BUILD
OUTPUT prepare_cmds
COMMAND ln -s -f ${CMAKE_HOME_DIRECTORY}/testdata)
add_custom_target(prepare ALL
DEPENDS prepare_cmds)
endfunction()
function (build_llvm)
execute_process(COMMAND sh -c "git -C ${CMAKE_HOME_DIRECTORY}/third_party/llvm-project log -1 --format=%H"
RESULT_VARIABLE clang_version_status
OUTPUT_VARIABLE CLANG_VERSION_OUTPUT)
set(CLANG_KNOWN_GIT_COMMIT_HASH "9fde1a498f2dc97a737a3564cb427c6f2a7bfe6c")
if (clang_version_status)
message(WARNING "Could not get clang commit hash : Use clang git hash " ${CLANG_KNOWN_GIT_COMMIT_HASH})
else()
string(REGEX MATCH "([0-9|a-f]+)" CLANG_GIT_COMMIT_HASH ${CLANG_VERSION_OUTPUT})
if ("${CLANG_GIT_COMMIT_HASH}" STREQUAL ${CLANG_KNOWN_GIT_COMMIT_HASH})
message(STATUS "Found known git commit hash of clang (" ${CLANG_GIT_COMMIT_HASH} ") - Success")
else()
message(FATAL_ERROR "Unverified git commit hash of llvm source - ${CLANG_GIT_COMMIT_HASH}. Do not modify or update third_party/llvm-project")
endif()
endif()
# Disable GFLAGS and UNWIND for glog, we do not control glog using
# gflags, nor does call stacks used in log information. And glog
# does not provide a way to force static link these two libraries.
set (WITH_GFLAGS OFF)
set (WITH_UNWIND OFF)
### LLVM Configuration
set (LLVM_INCLUDE_UTILS OFF)
set (LLVM_INCLUDE_TESTS OFF)
set (LLVM_INCLUDE_TOOLS OFF)
set (LLVM_INCLUDE_DOCS OFF)
set (LLVM_ENABLE_RTTI ON)
set (LLVM_ENABLE_PROJECTS clang CACHE STRING
"Semicolon-separated list of projects to build (${LLVM_KNOWN_PROJECTS}), or \"all\".")
set (LLVM_TARGETS_TO_BUILD X86 AArch64 CACHE STRING
"Semicolon-separated list of LLVM targets to build, or \"all\".")
set (LLVM_ENABLE_ZSTD FORCE_ON)
if (NOT ${BUILD_SHARED})
set (LLVM_USE_STATIC_ZSTD TRUE CACHE BOOL "use static zstd")
endif()
# terminfo is not needed by create_llvm_prof
set (LLVM_ENABLE_TERMINFO OFF CACHE BOOL "enable terminfo")
###
add_subdirectory(third_party/abseil)
add_subdirectory(third_party/glog)
add_subdirectory(third_party/googletest)
add_subdirectory(third_party/llvm-project/llvm)
add_custom_target(exclude_extlib_tests ALL
COMMAND rm -f ${gtest_BINARY_DIR}/CTestTestfile.cmake
COMMAND rm -f ${gmock_BINARY_DIR}/CTestTestfile.cmake
COMMAND rm -f ${googletest-distribution_BINARY_DIR}/CTestTestfile.cmake
COMMAND rm -f ${glog_BINARY_DIR}/CTestTestfile.cmake
COMMAND rm -f ${absl_BINARY_DIR}/CTestTestfile.cmake)
add_definitions(-DHAVE_LLVM=1)
include_directories(${CMAKE_HOME_DIRECTORY}
third_party/glog/src
third_party/abseil
third_party/llvm-project/llvm/include
third_party/perf_data_converter/src
third_party/perf_data_converter/src/quipper
${PROJECT_BINARY_DIR}
${PROJECT_BINARY_DIR}/third_party/glog
${PROJECT_BINARY_DIR}/third_party/llvm-project/llvm/include
${gtest_SOURCE_DIR}/include
${gmock_SOURCE_DIR}/include
third_party/perf_data_converter/src
third_party/perf_data_converter/src/quipper
util/regexp)
add_library(llvm_propeller_cfg_proto llvm_propeller_cfg.proto)
protobuf_generate(TARGET llvm_propeller_cfg_proto LANGUAGE cpp)
target_link_libraries(llvm_propeller_cfg_proto PUBLIC protobuf::libprotobuf)
add_library(llvm_propeller_options_proto llvm_propeller_options.proto)
target_link_libraries(llvm_propeller_options_proto PUBLIC
protobuf::libprotobuf)
protobuf_generate(
TARGET llvm_propeller_options_proto
LANGUAGE cpp)
add_library(llvm_propeller_options STATIC llvm_propeller_options_builder.cc)
target_link_libraries(llvm_propeller_options quipper_perf llvm_propeller_options_proto)
add_library(mini_disassembler OBJECT mini_disassembler.cc)
target_link_libraries(mini_disassembler
absl::base
absl::status
absl::statusor
LLVMMC
LLVMObject
LLVMSupport
LLVMTargetParser)
foreach (tgt ${LLVM_TARGETS_TO_BUILD})
set( tp ${PROJECT_BINARY_DIR}/third_party/llvm-project/llvm/lib/libLLVM${tgt})
foreach (tool AsmParser Desc Disassembler Info)
target_link_libraries(mini_disassembler LLVM${tgt}${tool})
endforeach()
endforeach()
add_library(sample_reader OBJECT sample_reader.cc spe_sample_reader.cc)
target_include_directories(sample_reader PUBLIC util)
target_link_libraries(sample_reader absl::base quipper_perf perf_proto LLVMObject)
add_dependencies(sample_reader llvm_propeller_objects)
add_library(perfdata_reader OBJECT perfdata_reader.cc)
target_include_directories(perfdata_reader
PUBLIC ${PROJECT_BINARY_DIR}/third_party/perf_data_converter/src/quipper)
target_link_libraries(perfdata_reader PUBLIC perf_proto)
add_library(symbol_map OBJECT
source_info.cc
symbol_map.cc
util/symbolize/elf_reader.cc)
target_include_directories(symbol_map PUBLIC util)
target_link_libraries(symbol_map
absl::flat_hash_map
absl::node_hash_set
absl::strings
absl::memory
absl::flags
glog
LLVMCore
LLVMProfileData)
add_library(llvm_profile_writer OBJECT
gcov.cc
llvm_profile_writer.cc
profile_writer.cc)
add_dependencies(llvm_profile_writer quipper_perf)
target_include_directories(llvm_profile_writer PUBLIC
third_party/perf_data_converter/src
third_party/perf_data_converter/src/quipper
util/regexp
${PROTOBUF_INCLUDE_DIR}
${PROJECT_BINARY_DIR}/third_party/perf_data_converter/src/quipper)
target_link_libraries(llvm_profile_writer
absl::flat_hash_map
absl::node_hash_set
absl::flags
symbol_map)
add_library(llvm_profile_reader OBJECT llvm_profile_reader.cc)
target_link_libraries(llvm_profile_reader
absl::flat_hash_map
absl::node_hash_set
symbol_map)
add_library(profile_reader OBJECT profile_reader.cc)
add_dependencies(profile_reader LLVMCore)
add_library(profile_creator OBJECT
addr2line.cc
instruction_map.cc
profile.cc
profile_creator.cc
profile_symbol_list.cc)
target_include_directories(profile_creator PUBLIC
third_party/perf_data_converter/src
third_party/perf_data_converter/src/quipper
util/regexp)
target_link_libraries(profile_creator
llvm_profile_writer
sample_reader)
add_executable(profile_diff profile_diff.cc)
target_link_libraries(profile_diff
absl::flags_parse
llvm_profile_reader
symbol_map
LLVMSupport)
add_executable(profile_merger profile_merger.cc)
target_link_libraries(profile_merger
absl::flags_parse
llvm_profile_reader
llvm_profile_writer
llvm_propeller_objects
llvm_propeller_perf_data_provider
mini_disassembler
perfdata_reader
profile_creator
profile_reader
quipper_perf
sample_reader
status_provider
symbol_map
LLVMDebugInfoDWARF
LLVMSupport)
add_executable(sample_merger sample_merger.cc)
target_link_libraries(sample_merger
absl::flags_parse
llvm_profile_reader
llvm_profile_writer
llvm_propeller_objects
llvm_propeller_perf_data_provider
mini_disassembler
perfdata_reader
profile_creator
quipper_perf
sample_reader
status_provider
symbol_map
LLVMDebugInfoDWARF
LLVMSupport)
add_executable(create_llvm_prof create_llvm_prof.cc)
target_link_libraries(create_llvm_prof
absl::base
absl::check
absl::flags
absl::flags_parse
absl::status
absl::statusor
absl::str_format
absl::strings
glog
llvm_profile_reader
llvm_profile_writer
llvm_propeller_objects
llvm_propeller_perf_data_provider
mini_disassembler
perfdata_reader
profile_creator
quipper_perf
sample_reader
status_provider
symbol_map
status_provider
LLVMDebugInfoDWARF
LLVMSupport)
add_executable(symbol_map_test symbol_map_test.cc)
target_link_libraries(symbol_map_test
gtest
gtest_main
llvm_profile_reader
symbol_map
LLVMSupport)
add_test(NAME symbol_map_test COMMAND symbol_map_test)
find_library (LIBELF_LIBRARIES NAMES elf REQUIRED)
find_library (LIBZ_LIBRARIES NAMES z REQUIRED)
find_library (LIBCRYPTO_LIBRARIES NAMES crypto REQUIRED)
add_executable(llvm_profile_reader_test llvm_profile_reader_test.cc)
target_link_libraries(llvm_profile_reader_test
gtest
gtest_main
llvm_profile_reader
symbol_map
LLVMSupport)
add_test(NAME llvm_profile_reader_test COMMAND llvm_profile_reader_test)
add_executable(llvm_profile_writer_test llvm_profile_writer_test.cc)
target_include_directories(llvm_profile_writer_test PUBLIC
third_party/perf_data_converter/src
third_party/perf_data_converter/src/quipper
util/regexp)
target_link_libraries(llvm_profile_writer_test
gtest
gtest_main
llvm_profile_writer
llvm_propeller_objects
llvm_propeller_perf_data_provider
mini_disassembler
perfdata_reader
profile_creator
quipper_perf
sample_reader
status_provider
symbol_map
LLVMDebugInfoDWARF
LLVMProfileData
LLVMSupport)
add_test(NAME llvm_profile_writer_test COMMAND llvm_profile_writer_test)
add_library(status_provider OBJECT
status_provider.cc
status_consumer_registry.cc)
add_library(llvm_propeller_perf_data_provider OBJECT
llvm_propeller_file_perf_data_provider.cc)
add_library(llvm_propeller_test_objects OBJECT
llvm_propeller_cfg_testutil.cc
llvm_propeller_function_cluster_info_matchers.cc
llvm_propeller_mock_program_cfg_builder.cc)
target_include_directories(llvm_propeller_test_objects
PUBLIC ${PROTOBUF_INCLUDE_DIR})
target_link_libraries(llvm_propeller_test_objects
llvm_propeller_cfg_proto)
add_library(llvm_propeller_objects OBJECT
addr2cu.cc
branch_aggregation.cc
branch_frequencies_autofdo_sample.cc
frequencies_branch_aggregator.cc
lbr_branch_aggregator.cc
llvm_propeller_binary_address_mapper.cc
llvm_propeller_binary_content.cc
llvm_propeller_cfg.cc
llvm_propeller_chain_cluster_builder.cc
llvm_propeller_code_layout.cc
llvm_propeller_code_layout_scorer.cc
llvm_propeller_formatting.cc
llvm_propeller_node_chain.cc
llvm_propeller_node_chain_assembly.cc
llvm_propeller_node_chain_builder.cc
llvm_propeller_perf_branch_frequencies_aggregator.cc
llvm_propeller_perf_lbr_aggregator.cc
llvm_propeller_profile_computer.cc
llvm_propeller_profile_generator.cc
llvm_propeller_profile_writer.cc
llvm_propeller_program_cfg.cc
llvm_propeller_program_cfg_builder.cc
llvm_propeller_program_cfg_proto_builder.cc
llvm_propeller_statistics.cc
llvm_propeller_telemetry_reporter.cc
spe_tid_pid_provider.cc)
target_link_libraries(llvm_propeller_objects
absl::statusor
llvm_profile_writer
llvm_propeller_options
llvm_propeller_cfg_proto
status_provider
LLVMDebugInfoDWARF)
add_executable(instruction_map_test addr2line.cc instruction_map.cc instruction_map_test.cc)
target_link_libraries(instruction_map_test
gtest
gtest_main
llvm_propeller_objects
llvm_propeller_perf_data_provider
mini_disassembler
perfdata_reader
quipper_perf
sample_reader
status_provider
symbol_map
LLVMDebugInfoDWARF
LLVMSupport)
add_test(NAME instruction_map_test COMMAND instruction_map_test)
add_executable(profile_symbol_list_test profile_symbol_list.cc)
target_link_libraries(profile_symbol_list_test
gtest
gtest_main
symbol_map
LLVMSupport)
add_test(NAME profile_symbol_list_test COMMAND profile_symbol_list_test)
add_executable(sample_reader_test sample_reader_test.cc)
target_link_libraries(sample_reader_test
absl::base
absl::check
absl::strings
glog
gtest
gtest_main
llvm_profile_writer
llvm_propeller_objects
llvm_propeller_perf_data_provider
mini_disassembler
perfdata_reader
quipper_perf
sample_reader
status_provider
symbol_map
LLVMObject
LLVMDebugInfoDWARF
LLVMSupport)
add_test(NAME sample_reader_test COMMAND sample_reader_test)
add_executable(addr2cu_test addr2cu_test.cc)
target_link_libraries(addr2cu_test
absl::base
gtest
gtest_main
llvm_profile_writer
llvm_propeller_objects
llvm_propeller_perf_data_provider
mini_disassembler
perfdata_reader
quipper_perf
status_provider
symbol_map)
add_test(NAME addr2cu_test COMMAND addr2cu_test)
add_executable(branch_frequencies_autofdo_sample_test branch_frequencies_autofdo_sample_test.cc)
target_link_libraries(branch_frequencies_autofdo_sample_test
gmock
gtest
gtest_main
llvm_profile_writer
llvm_propeller_objects
llvm_propeller_perf_data_provider
mini_disassembler
perfdata_reader
quipper_perf
status_provider
symbol_map)
add_test(NAME branch_frequencies_autofdo_sample_test COMMAND branch_frequencies_autofdo_sample_test)
add_executable(lbr_branch_aggregator_test lbr_branch_aggregator_test.cc)
target_link_libraries(lbr_branch_aggregator_test
gmock
gtest
gtest_main
llvm_profile_writer
llvm_propeller_objects
llvm_propeller_perf_data_provider
mini_disassembler
perfdata_reader
quipper_perf
status_provider
symbol_map)
add_test(NAME lbr_branch_aggregator_test COMMAND lbr_branch_aggregator_test)
add_executable(llvm_propeller_binary_address_mapper_test llvm_propeller_binary_address_mapper_test.cc)
target_link_libraries(llvm_propeller_binary_address_mapper_test
gmock
gtest
gtest_main
llvm_profile_writer
llvm_propeller_objects
llvm_propeller_perf_data_provider
mini_disassembler
perfdata_reader
quipper_perf
status_provider
symbol_map)
add_test(NAME llvm_propeller_binary_address_mapper_test COMMAND llvm_propeller_binary_address_mapper_test)
add_executable(llvm_propeller_cfg_test llvm_propeller_cfg_test.cc)
target_link_libraries(llvm_propeller_cfg_test
gmock
gtest
gtest_main
llvm_profile_writer
llvm_propeller_objects
llvm_propeller_perf_data_provider
llvm_propeller_test_objects
mini_disassembler
perfdata_reader
quipper_perf
status_provider
symbol_map)
add_test(NAME llvm_propeller_cfg_test COMMAND llvm_propeller_cfg_test)
add_executable(llvm_propeller_file_perf_data_provider_test llvm_propeller_file_perf_data_provider_test.cc)
target_link_libraries(llvm_propeller_file_perf_data_provider_test
gmock
gtest
gtest_main
llvm_profile_writer
llvm_propeller_objects
llvm_propeller_perf_data_provider
mini_disassembler
perfdata_reader
quipper_perf
status_provider
symbol_map)
add_test(NAME llvm_propeller_file_perf_data_provider_test COMMAND llvm_propeller_file_perf_data_provider_test)
add_executable(llvm_propeller_perf_branch_frequencies_aggregator_test llvm_propeller_perf_branch_frequencies_aggregator_test.cc)
target_link_libraries(llvm_propeller_perf_branch_frequencies_aggregator_test
gmock
gtest
gtest_main
llvm_profile_writer
llvm_propeller_objects
llvm_propeller_perf_data_provider
mini_disassembler
perfdata_reader
quipper_perf
status_provider
symbol_map)
add_test(NAME llvm_propeller_perf_branch_frequencies_aggregator_test COMMAND llvm_propeller_perf_branch_frequencies_aggregator_test)
add_executable(llvm_propeller_perf_lbr_aggregator_test llvm_propeller_perf_lbr_aggregator_test.cc)
target_link_libraries(llvm_propeller_perf_lbr_aggregator_test
gtest_main
llvm_profile_writer
llvm_propeller_objects
llvm_propeller_perf_data_provider
mini_disassembler
perfdata_reader
quipper_perf
status_provider
symbol_map)
add_test(NAME llvm_propeller_perf_lbr_aggregator_test COMMAND llvm_propeller_perf_lbr_aggregator_test)
add_executable(llvm_propeller_profile_computer_test llvm_propeller_profile_computer_test.cc)
target_link_libraries(llvm_propeller_profile_computer_test
gmock
gtest
gtest_main
llvm_profile_writer
llvm_propeller_objects
llvm_propeller_perf_data_provider
mini_disassembler
perfdata_reader
quipper_perf
status_provider
symbol_map)
add_test(NAME llvm_propeller_profile_computer_test COMMAND llvm_propeller_profile_computer_test)
add_executable(llvm_propeller_profile_generator_test llvm_propeller_profile_generator_test.cc)
target_link_libraries(llvm_propeller_profile_generator_test
gmock
gtest
gtest_main
llvm_profile_writer
llvm_propeller_objects
llvm_propeller_perf_data_provider
mini_disassembler
perfdata_reader
quipper_perf
status_provider
symbol_map)
add_test(NAME llvm_propeller_profile_generator_test COMMAND llvm_propeller_profile_generator_test)
add_executable(llvm_propeller_program_cfg_builder_test llvm_propeller_program_cfg_builder_test.cc)
target_link_libraries(llvm_propeller_program_cfg_builder_test
gmock
gtest
gtest_main
llvm_profile_writer
llvm_propeller_objects
llvm_propeller_perf_data_provider
mini_disassembler
perfdata_reader
quipper_perf
status_provider
symbol_map)
add_test(NAME llvm_propeller_program_cfg_builder_test COMMAND llvm_propeller_program_cfg_builder_test)
add_executable(llvm_propeller_program_cfg_proto_builder_test llvm_propeller_program_cfg_proto_builder_test.cc)
target_link_libraries(llvm_propeller_program_cfg_proto_builder_test
gtest
gtest_main
llvm_profile_writer
llvm_propeller_objects
llvm_propeller_perf_data_provider
mini_disassembler
perfdata_reader
quipper_perf
status_provider
symbol_map)
add_test(NAME llvm_propeller_program_cfg_proto_builder_test COMMAND llvm_propeller_program_cfg_proto_builder_test)
add_executable(llvm_propeller_program_cfg_test llvm_propeller_program_cfg_test.cc)
target_link_libraries(llvm_propeller_program_cfg_test
gmock
gtest
gtest_main
llvm_profile_writer
llvm_propeller_objects
llvm_propeller_test_objects
llvm_propeller_perf_data_provider
mini_disassembler
perfdata_reader
quipper_perf
status_provider
symbol_map)
add_test(NAME llvm_propeller_program_cfg_test COMMAND llvm_propeller_program_cfg_test)
add_executable(llvm_propeller_statistics_test llvm_propeller_statistics_test.cc)
target_link_libraries(llvm_propeller_statistics_test
gtest
gtest_main
llvm_profile_writer
llvm_propeller_objects
llvm_propeller_perf_data_provider
mini_disassembler
perfdata_reader
quipper_perf
status_provider
symbol_map)
add_test(NAME llvm_propeller_statistics_test COMMAND llvm_propeller_statistics_test)
add_executable(perfdata_reader_test perfdata_reader_test.cc)
target_link_libraries(perfdata_reader_test
gmock
gtest
gtest_main
llvm_profile_writer
llvm_propeller_objects
llvm_propeller_perf_data_provider
mini_disassembler
perfdata_reader
quipper_perf
status_provider
symbol_map)
add_test(NAME perfdata_reader_test COMMAND perfdata_reader_test)
add_executable(spe_sample_reader_test spe_sample_reader_test.cc)
target_link_libraries(spe_sample_reader_test
gtest
gtest_main
llvm_profile_writer
llvm_propeller_objects
llvm_propeller_perf_data_provider
mini_disassembler
perfdata_reader
quipper_perf
sample_reader
status_provider
symbol_map)
add_test(NAME spe_sample_reader_test COMMAND spe_sample_reader_test)
add_executable(llvm_propeller_code_layout_test llvm_propeller_code_layout_test.cc)
target_link_libraries(llvm_propeller_code_layout_test
gmock
gtest
gtest_main
llvm_profile_writer
llvm_propeller_objects
llvm_propeller_perf_data_provider
llvm_propeller_test_objects
mini_disassembler
perfdata_reader
quipper_perf
status_provider
symbol_map)
add_test(NAME llvm_propeller_code_layout_test COMMAND llvm_propeller_code_layout_test)
add_library(llvm_propeller_cfg OBJECT llvm_propeller_cfg.cc)
add_library(llvm_propeller_formatting OBJECT llvm_propeller_formatting.cc)
add_library(quipper_perf OBJECT
third_party/perf_data_converter/src/quipper/address_mapper.cc
third_party/perf_data_converter/src/quipper/arm_spe_decoder.cc
third_party/perf_data_converter/src/quipper/base/logging.cc
third_party/perf_data_converter/src/quipper/binary_data_utils.cc
third_party/perf_data_converter/src/quipper/binary_data_utils.cc
third_party/perf_data_converter/src/quipper/buffer_reader.cc
third_party/perf_data_converter/src/quipper/buffer_writer.cc
third_party/perf_data_converter/src/quipper/compat/log_level.cc
third_party/perf_data_converter/src/quipper/data_reader.cc
third_party/perf_data_converter/src/quipper/data_writer.cc
third_party/perf_data_converter/src/quipper/dso.cc
third_party/perf_data_converter/src/quipper/file_reader.cc
third_party/perf_data_converter/src/quipper/file_utils.cc
third_party/perf_data_converter/src/quipper/huge_page_deducer.cc
third_party/perf_data_converter/src/quipper/perf_buildid.cc
third_party/perf_data_converter/src/quipper/perf_data_utils.cc
third_party/perf_data_converter/src/quipper/perf_serializer.cc
third_party/perf_data_converter/src/quipper/perf_reader.cc
third_party/perf_data_converter/src/quipper/perf_parser.cc
third_party/perf_data_converter/src/quipper/sample_info_reader.cc
third_party/perf_data_converter/src/quipper/string_utils.cc)
target_include_directories(quipper_perf PRIVATE
third_party/abseil)
target_include_directories(quipper_perf BEFORE
PUBLIC
third_party/perf_data_converter/src
third_party/perf_data_converter/src/quipper
${PROJECT_BINARY_DIR}/third_party/perf_data_converter/src/quipper)
target_link_libraries(quipper_perf
perf_proto ${LIBELF_LIBRARIES} ${LIBZ_LIBRARIES} ${LIBCRYPTO_LIBRARIES})
add_custom_command(PRE_BUILD
OUTPUT prepare_cmds
COMMAND ln -s -f ${CMAKE_HOME_DIRECTORY}/testdata)
add_custom_target(prepare ALL
DEPENDS prepare_cmds)
endfunction()
if (DEFINED ENABLE_TOOL)
string(TOLOWER ${ENABLE_TOOL} enable_tool)
else()
set(enable_tool llvm)
endif()
# perf protobuf is required by both tools.
execute_perf_protobuf()
if (${enable_tool} STREQUAL gcov)
message(STATUS "Building tool \"GCOV\" ...")
build_gcov()
elseif (${enable_tool} STREQUAL llvm)
message(STATUS "Building tool \"LLVM\" ...")
if (NOT ${BUILD_SHARED})
# Build static binaries.
set (BUILD_SHARED_LIBS OFF)
set (CMAKE_FIND_LIBRARY_SUFFIXES ".a")
# Link static executables.
set (CMAKE_EXE_LINKER_FLAGS "-static")
endif()
build_llvm()
else ()
message(FATAL_ERROR
"ENABLE_TOOL must equal to one of \"LLVM\" (default) or \"GCOV\"")
endif ()
enable_testing()