Skip to content

Commit

Permalink
thread OK leak maybe not
Browse files Browse the repository at this point in the history
  • Loading branch information
galabovaa committed Sep 17, 2024
1 parent aa13d7a commit 04a2df0
Showing 1 changed file with 37 additions and 11 deletions.
48 changes: 37 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ if (PYTHON_BUILD_SETUP)
set(ZLIB OFF)
endif()

option(DEBUG_MEMORY "DEBUG_MEMORY" OFF)
# option(DEBUG_MEMORY "DEBUG_MEMORY" OFF)
# Address | Thread | Leak
# Linux atm
# Only Debug atm
set(DEBUG_MEMORY "Off" CACHE STRING "Sanitizers")

# emscripten
option(EMSCRIPTEN_HTML "Emscripten HTML output" OFF)
Expand Down Expand Up @@ -390,21 +394,38 @@ message(STATUS "Git hash: " ${GITHASH})

configure_file(${HIGHS_SOURCE_DIR}/src/HConfig.h.in ${HIGHS_BINARY_DIR}/HConfig.h)

if (DEBUG_MEMORY)
# set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fno-omit-frame-pointer -fsanitize=address -fsanitize=undefined")
# set (CMAKE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_LINKER_FLAGS_RELWITHDEBINFO} -fno-omit-frame-pointer -fsanitize=address -fsanitize=undefined")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
if (DEBUG_MEMORY STREQUAL "Address")
# set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}
# -fsanitize=thread,undefined
# -fno-omit-frame-pointer
# -fsanitize-address-use-after-scope")
# set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}
# -fsanitize=thread,undefined
# -fno-omit-frame-pointer
# -fsanitize-address-use-after-scope")

# set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address,undefined -fno-optimize-sibling-calls ")
# set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address,undefined -fno-optimize-sibling-calls ")
# set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}
# -fsanitize=address,undefined
# -fno-omit-frame-pointer
# -fno-optimize-sibling-calls ")
# set (CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}
# -fsanitize=address,undefined
# -fno-omit-frame-pointer
# -fno-optimize-sibling-calls ")

# set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address,undefined")
# set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address,undefined")
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address,undefined ")
set (CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fsanitize=address,undefined")

set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=thread,undefined -O0 -g")
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=thread,undefined -O0 -g")
elseif (DEBUG_MEMORY STREQUAL "Thread")

#-fsanitize=memory -fPIE -pie
# set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=thread,undefined -O0 -g")
# set (CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=thread,undefined -O0 -g")

set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=thread,undefined -fno-omit-frame-pointer ")
set (CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fsanitize=thread,undefined -fno-omit-frame-pointer ")

elseif (DEBUG_MEMORY STREQUAL "Leak")

# # AddressSanitize
# set(CMAKE_C_FLAGS_ASAN
Expand All @@ -415,6 +436,11 @@ if (DEBUG_MEMORY)
# "-fsanitize=address -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer -g -O1"
# CACHE STRING "Flags used by the C++ compiler during AddressSanitizer builds."
# FORCE)

set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=leak")
set (CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fsanitize=leak ")

endif()
endif()

if(NOT FAST_BUILD)
Expand Down

0 comments on commit 04a2df0

Please sign in to comment.