forked from klee/klee
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cmake] Add support to generate arbitrary runtime library configurations
Every runtime library can be build with multiple configurations. Replace the Makefile-based setup by cmake one. Currently, we generate 32bit and 64bit libraries simultaneously and can link against them.
- Loading branch information
1 parent
5b8e54a
commit 6156b4e
Showing
16 changed files
with
300 additions
and
481 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#===------------------------------------------------------------------------===# | ||
# | ||
# The KLEE Symbolic Virtual Machine | ||
# | ||
# This file is distributed under the University of Illinois Open Source | ||
# License. See LICENSE.TXT for details. | ||
# | ||
#===------------------------------------------------------------------------===# | ||
function(compile_bitcode_library library_name source_files compile_cc_flags compile_cxx_flags opt_suffix) | ||
# Compile every source file | ||
set(BC_FILES) | ||
foreach(source_file ${source_files}) | ||
# Get filename without extension | ||
get_filename_component(file_name_only "${source_file}" NAME_WE) | ||
set(bc_file "${CMAKE_CURRENT_BINARY_DIR}/${file_name_only}${opt_suffix}.bc" ) | ||
get_filename_component(source_file_type "${source_file}" EXT) | ||
if("${source_file_type}" STREQUAL ".cpp") | ||
add_custom_command( | ||
OUTPUT ${bc_file} | ||
COMMAND ${LLVMCXX} -c "-emit-llvm" ${compile_cxx_flags} "${source_file}" -o ${bc_file} | ||
DEPENDS ${source_file} | ||
) | ||
else() | ||
add_custom_command( | ||
OUTPUT ${bc_file} | ||
COMMAND ${LLVMCC} -c "-emit-llvm" ${compile_cc_flags} "${source_file}" -o ${bc_file} | ||
DEPENDS ${source_file} | ||
) | ||
endif() | ||
|
||
list(APPEND BC_FILES ${bc_file}) | ||
endforeach() | ||
|
||
# Add command to link them to an archive | ||
add_custom_command( | ||
OUTPUT ${library_name} | ||
COMMAND ${LLVM_AR} rcs ${library_name} ${BC_FILES} | ||
DEPENDS ${BC_FILES} | ||
) | ||
endfunction(compile_bitcode_library) | ||
|
||
function(prefix_with_path files prefix output_var) | ||
set(_result) | ||
foreach(file ${files}) | ||
list(APPEND _result "${prefix}${file}") | ||
endforeach() | ||
set(${output_var} "${_result}" PARENT_SCOPE) | ||
endfunction(prefix_with_path) | ||
|
||
function(add_bitcode_library_targets lib_prefix prefixed_files cc_extra_args cxx_extra_args) | ||
set(_lib_dependencies) | ||
foreach(_suffix ${LIB_BC_SUFFIX}) | ||
set(final_cc_flags ${LIB_BC_FLAGS_${_suffix}} ${cc_extra_args}) | ||
set(final_cxx_flags ${LIB_BC_FLAGS_${_suffix}} ${cxx_extra_args}) | ||
compile_bitcode_library("${KLEE_RUNTIME_DIRECTORY}/libklee${lib_prefix}${_suffix}.bca" "${prefixed_files}" "${final_cc_flags}" "${final_cxx_flags}" "${_suffix}") | ||
list(APPEND _lib_dependencies "${KLEE_RUNTIME_DIRECTORY}/libklee${lib_prefix}${_suffix}.bca") | ||
endforeach() | ||
|
||
add_custom_target(${lib_prefix} DEPENDS "${_lib_dependencies}") | ||
endfunction(add_bitcode_library_targets) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#===------------------------------------------------------------------------===# | ||
# | ||
# The KLEE Symbolic Virtual Machine | ||
# | ||
# This file is distributed under the University of Illinois Open Source | ||
# License. See LICENSE.TXT for details. | ||
# | ||
#===------------------------------------------------------------------------===# | ||
|
||
set(LIB_PREFIX "RuntimeFreeStanding") | ||
set(SRC_FILES | ||
memcmp.c | ||
memcpy.c | ||
memmove.c | ||
memset.c | ||
) | ||
|
||
# Build it | ||
include("${CMAKE_SOURCE_DIR}/cmake/compile_bitcode_library.cmake") | ||
prefix_with_path("${SRC_FILES}" "${CMAKE_CURRENT_SOURCE_DIR}/" prefixed_files) | ||
add_bitcode_library_targets("${LIB_PREFIX}" "${prefixed_files}" "" "") |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#===------------------------------------------------------------------------===# | ||
# | ||
# The KLEE Symbolic Virtual Machine | ||
# | ||
# This file is distributed under the University of Illinois Open Source | ||
# License. See LICENSE.TXT for details. | ||
# | ||
#===------------------------------------------------------------------------===# | ||
# Set up | ||
set(LIB_PREFIX "RuntimeIntrinsic") | ||
set(SRC_FILES | ||
dso_handle.c | ||
klee_choose.c | ||
klee_div_zero_check.c | ||
klee_int.c | ||
klee_is_replay.c | ||
klee_overshift_check.c | ||
klee_range.c | ||
) | ||
|
||
# Build it | ||
include("${CMAKE_SOURCE_DIR}/cmake/compile_bitcode_library.cmake") | ||
prefix_with_path("${SRC_FILES}" "${CMAKE_CURRENT_SOURCE_DIR}/" prefixed_files) | ||
add_bitcode_library_targets("${LIB_PREFIX}" "${prefixed_files}" "-std=gnu89" "") |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.