Index: utils/perf-training/CMakeLists.txt =================================================================== --- utils/perf-training/CMakeLists.txt +++ utils/perf-training/CMakeLists.txt @@ -30,13 +30,18 @@ endif() if(NOT LLVM_PROFDATA) - message(FATAL_ERROR "Must set LLVM_PROFDATA to point to llvm-profdata to use for merging PGO data") + set(LLVM_PROFDATA ${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-profdata) + message(STATUS "LLVM_PROFDATA is set to point to llvm-profdata built from the sources") + set(GENERATE_PROFDATA_DEPENDS_ON_LLVM_PROFTDATA TRUE) endif() - + add_custom_target(generate-profdata COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py merge ${LLVM_PROFDATA} ${CMAKE_CURRENT_BINARY_DIR}/clang.profdata ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Merging profdata" DEPENDS generate-profraw) + if (GENERATE_PROFDATA_DEPENDS_ON_LLVM_PROFTDATA) + add_dependencies(generate-profdata llvm-profdata) + endif() endif() find_program(DTRACE dtrace)