Rebase: [NFC] Refactor sources to be buildable in shared mode
Summary: Moves source files into separate components, and make explicit component dependency on each other, so LLVM build system knows how to build BOLT in BUILD_SHARED_LIBS=ON. Please use the -c merge.renamelimit=230 git option when rebasing your work on top of this change. To achieve this, we create a new library to hold core IR files (most classes beginning with Binary in their names), a new library to hold Utils, some command line options shared across both RewriteInstance and core IR files, a new library called Rewrite to hold most classes concerned with running top-level functions coordinating the binary rewriting process, and a new library called Profile to hold classes dealing with profile reading and writing. To remove the dependency from BinaryContext into X86-specific classes, we do some refactoring on the BinaryContext constructor to receive a reference to the specific backend directly from RewriteInstance. Then, the dependency on X86 or AArch64-specific classes is transfered to the Rewrite library. We can't have the Core library depend on targets because targets depend on Core (which would create a cycle). Files implementing the entry point of a tool are transferred to the tools/ folder. All header files are transferred to the include/ folder. The src/ folder was renamed to lib/. (cherry picked from FBD32746834)
This commit is contained in:
committed by
Maksim Panchenko
parent
46bc197d72
commit
a34c753fe7
53
bolt/lib/Utils/CMakeLists.txt
Normal file
53
bolt/lib/Utils/CMakeLists.txt
Normal file
@@ -0,0 +1,53 @@
|
||||
# Get the current git revision for BOLT.
|
||||
function(get_version ofn)
|
||||
find_program(git_executable NAMES git git.exe git.cmd)
|
||||
if (git_executable)
|
||||
execute_process(COMMAND ${git_executable} rev-parse HEAD
|
||||
WORKING_DIRECTORY ${LLVM_MAIN_SRC_DIR}
|
||||
TIMEOUT 5
|
||||
RESULT_VARIABLE git_result
|
||||
OUTPUT_VARIABLE git_output)
|
||||
if( git_result EQUAL 0 )
|
||||
string(STRIP "${git_output}" git_ref_id)
|
||||
set(BOLT_REVISION "${git_ref_id}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# If we can't find a revision, set it to "<unknown>".
|
||||
if (NOT BOLT_REVISION)
|
||||
set(BOLT_REVISION "<unknown>")
|
||||
endif()
|
||||
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
|
||||
COMMAND echo '"${BOLT_REVISION}"' > ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
|
||||
COMMENT "Generating bogus ${ofn}..."
|
||||
)
|
||||
|
||||
set(VERSION_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn} PARENT_SCOPE)
|
||||
|
||||
# `make clean' must remove all those generated files:
|
||||
set_property(DIRECTORY APPEND
|
||||
PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${ofn})
|
||||
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${ofn} PROPERTIES
|
||||
GENERATED 1)
|
||||
endfunction()
|
||||
|
||||
# Creates a public target for generating the revision file.
|
||||
function(add_public_gen_version_target target)
|
||||
add_custom_target(${target} DEPENDS ${VERSION_OUTPUT})
|
||||
set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} ${target} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
get_version(BoltRevision.inc)
|
||||
add_public_gen_version_target(GenBoltRevision)
|
||||
|
||||
add_llvm_library(LLVMBOLTUtils
|
||||
CommandLineOpts.cpp
|
||||
Utils.cpp
|
||||
|
||||
LINK_LIBS
|
||||
${LLVM_PTHREAD_LIB}
|
||||
|
||||
LINK_COMPONENTS
|
||||
Support
|
||||
)
|
||||
Reference in New Issue
Block a user