Skip to content

Commit

Permalink
cmake: Clean up build type and install options.
Browse files Browse the repository at this point in the history
THIS INCLUDES BREAKING CHANGES.

1. Remove the DEBUG build option (forgot CMake already has such an
   option through CMAKE_BUILD_TYPE).
2. If no build type is specified, we build for release. Importantly,
   this means building with -O3.
3. Install directory is ${LLVM_HOME}, not ${LLVM_HOME}/install.
4. Remove BUILD_ON_SOURCE option - this is silly. If the user is going
   to build with CMake, he/she should it properly (i.e. build out of
   source and install with  `make install`). This is the breaking change
   - users of CMake will need to run `make install` and update their
   Makefiles to reflect the new installation directory structure (bin/
   and lib/ instead of full-trace/ and profile-func/).

Change-Id: Icbf32468b89716aa3f8baf504bfe2e9d66f38ceb
  • Loading branch information
xyzsam committed Sep 7, 2016
1 parent 40fb590 commit da0712a
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 33 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ cmake_minimum_required(VERSION 2.8.12)
project(LLVM_TRACER CXX)
enable_testing()

set(CMAKE_INSTALL_PREFIX $ENV{TRACER_HOME}/install)
set(CMAKE_INSTALL_PREFIX $ENV{TRACER_HOME})
set(SCRIPT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake-scripts")
include("${SCRIPT_DIR}/TracerConfig.cmake")
include("${SCRIPT_DIR}/findAndSetLLVM.cmake")

set(CMAKE_CXX_COMPILER ${CLANGXX})
option(DEBUG "Build in debugging mode (-O0, -g)" OFF)

add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/full-trace")
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/profile-func")
Expand Down
5 changes: 0 additions & 5 deletions ast-pass/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ add_definitions(
)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -std=c++11")
if (DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g")
else (DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
endif (DEBUG)

set(SOURCE_FILES GetLabeledStmts.cpp)
add_executable(get-labeled-stmts ${SOURCE_FILES})
Expand Down
13 changes: 8 additions & 5 deletions cmake-scripts/TracerConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,22 @@ STRING(REPLACE ";" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")

# sets debug level to g3, which contains more infomation than g2.
# to use it : cmake /where/source/code -DCMAKE_BUILD_TYPE=DEBUG
set(CMAKE_CXX_FLAGS_DEBUG -g3)
set(CMAKE_CXX_FLAGS_DEBUG "-g3 -O0")

# Builds an optimized tracer for release.
set(CMAKE_CXX_FLAGS_RELEASE "-O3")

# If we don't specify a build type, build for release.
if (CMAKE_BUILD_TYPE STREQUAL "")
set (CMAKE_BUILD_TYPE RELEASE)
endif()

if(NOT DEFINED TEST_CMAKE)
SET(TEST_CMAKE FALSE)
endif()

SET(RECOMMAND_LLVM_PREFIX ${CMAKE_BINARY_DIR}/lib/llvm-${LLVM_RECOMMEND_VERSION})

if(NOT DEFINED BUILD_ON_SOURCE)
SET(BUILD_ON_SOURCE TRUE)
endif()

if(NOT DEFINED AUTOINSTALL)
SET(AUTOINSTALL FALSE)
endif()
Expand Down
7 changes: 1 addition & 6 deletions cmake-scripts/buildTracerBitcode.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ function(build_tracer_bitcode TEST_NAME f_SRC WORKLOAD)
set(FULL_S "${CMAKE_CURRENT_BINARY_DIR}/full.s")
set(RAW_EXE "${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}")
set(PROFILE_EXE "${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}-instrumented")

if(${BUILD_ON_SOURCE})
set(TRACE_LOGGER "${CMAKE_CURRENT_SOURCE_DIR}/../../profile-func/trace_logger.${LLVM_EXT}")
else()
set(TRACE_LOGGER "${CMAKE_CURRENT_BINARY_DIR}/../../profile-func/trace_logger.${LLVM_EXT}")
endif()
set(TRACE_LOGGER "${CMAKE_CURRENT_BINARY_DIR}/../../profile-func/trace_logger.${LLVM_EXT}")

set(FULLTRACE_SO "$<TARGET_FILE:full_trace>")

Expand Down
10 changes: 0 additions & 10 deletions full-trace/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
if (DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g")
else (DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
endif (DEBUG)

file(GLOB SRC "*.cpp")
add_library(full_trace SHARED ${SRC})
install(TARGETS full_trace LIBRARY DESTINATION lib)

# remove name prefix in order not to generate libxxxxxx name
set_target_properties(full_trace PROPERTIES PREFIX "")

if(${BUILD_ON_SOURCE})
set_target_properties(full_trace PROPERTIES LIBRARY_OUTPUT_DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}")
endif()
6 changes: 1 addition & 5 deletions profile-func/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ file(GLOB SRC "*.c")

set(LLVMC_FLAGS ${LLVMC_FLAGS} "-O3")

if(${BUILD_ON_SOURCE})
build_llvm_bc(${FCTS} SRC ${CMAKE_CURRENT_SOURCE_DIR})
else()
build_llvm_bitcode(${FCTS} SRC)
endif()
build_llvm_bitcode(${FCTS} SRC)

add_custom_target(PROFILE_FUNC ALL DEPENDS ${FCTS})
install(FILES ${FCTS}.llvm DESTINATION lib)

0 comments on commit da0712a

Please sign in to comment.