Skip to content

Commit

Permalink
ASAN flag wasn't being passed to the IR compiler (cmu-db#550)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbutrovich authored Oct 8, 2019
1 parent cd670a3 commit 15098b6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 25 deletions.
31 changes: 16 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,6 @@ enable_testing()

include(ThirdpartyToolchain)

# Add common flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_COMMON_FLAGS}")

# For any C code, use the same flags.
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")

# Remove --std=c++17 to avoid errors from C compilers
string(REPLACE "-std=c++17" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})

# Add C++-only flags, like -std=c++17
set(CMAKE_CXX_FLAGS "${CXX_ONLY_FLAGS} ${CMAKE_CXX_FLAGS}")

# ASAN / TSAN / UBSAN
include(san-config)

Expand All @@ -193,11 +181,24 @@ if (TERRIER_GENERATE_COVERAGE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
endif ()

# Add common flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_COMMON_FLAGS}")

# For any C code, use the same flags.
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")

# Remove --std=c++17 to avoid errors from C compilers
string(REPLACE "-std=c++17" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})

# Add C++-only flags, like -std=c++17
set(CMAKE_CXX_FLAGS "${CXX_ONLY_FLAGS} ${CMAKE_CXX_FLAGS}")

# CMAKE_CXX_FLAGS now fully assembled
#message(STATUS "CXX_ONLY_FLAGS: ${CXX_ONLY_FLAGS}")
#message(STATUS "CXX_COMMON_FLAGS: ${CXX_COMMON_FLAGS}")
#message(STATUS "CXX_OPTIMIZATION_FLAGS: ${CXX_OPTIMIZATION_FLAGS}")
message(STATUS "CXX_ONLY_FLAGS: ${CXX_ONLY_FLAGS}")
message(STATUS "CXX_COMMON_FLAGS: ${CXX_COMMON_FLAGS}")
message(STATUS "CXX_OPTIMIZATION_FLAGS: ${CXX_OPTIMIZATION_FLAGS}")
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
message(STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")

###########################################################
# "make check-lint" and "make check-censored" targets
Expand Down
11 changes: 1 addition & 10 deletions cmake_modules/san-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if (${TERRIER_USE_ASAN})
message(SEND_ERROR "Cannot use dynamic linking when ASAN and UBSAN are both enabled")
endif ()
endif ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -DADDRESS_SANITIZER")
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -fsanitize=address")
message(STATUS "AddressSanitizer enabled.")
endif ()

Expand Down Expand Up @@ -90,15 +90,6 @@ if (${TERRIER_USE_TSAN})
endif ()
endif ()

if (${TERRIER_USE_COVERAGE})
if (NOT ("${COMPILER_FAMILY}" STREQUAL "clang"))
message(SEND_ERROR "You can only enable coverage with clang")
endif ()
add_definitions("-fsanitize-coverage=trace-pc-guard")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize-coverage=trace-pc-guard")
endif ()

if ("${TERRIER_USE_UBSAN}" OR "${TERRIER_USE_ASAN}" OR "${TERRIER_USE_TSAN}")
# GCC 4.8 and 4.9 (latest as of this writing) don't allow you to specify a
# sanitizer blacklist.
Expand Down

0 comments on commit 15098b6

Please sign in to comment.