Skip to content

Commit

Permalink
cmake: remove -O3 option for debug build
Browse files Browse the repository at this point in the history
For source line debug and code coverage, -O3 conflicts to other compiler options.
  • Loading branch information
kawakami-k authored and mgouicem committed Jan 12, 2021
1 parent cfb13a2 commit 303256f
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions cmake/platform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,25 @@ elseif(UNIX OR MINGW)
# compiler specific settings
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(DNNL_TARGET_ARCH STREQUAL "AARCH64")
set(DEF_ARCH_OPT_FLAGS "-O3")
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
set(DEF_ARCH_OPT_FLAGS "-O3")
endif()
# For native compilation tune for the host processor
if (CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR)
append(DEF_ARCH_OPT_FLAGS "-mcpu=native")
endif()
elseif(DNNL_TARGET_ARCH STREQUAL "PPC64")
set(DEF_ARCH_OPT_FLAGS "-O3")
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
set(DEF_ARCH_OPT_FLAGS "-O3")
endif()
# For native compilation tune for the host processor
if (CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR)
append(DEF_ARCH_OPT_FLAGS "-mcpu=native")
endif()
elseif(DNNL_TARGET_ARCH STREQUAL "S390X")
set(DEF_ARCH_OPT_FLAGS "-O3")
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
set(DEF_ARCH_OPT_FLAGS "-O3")
endif()
# For native compilation tune for the host processor
if (CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR)
append(DEF_ARCH_OPT_FLAGS "-march=native")
Expand Down Expand Up @@ -204,20 +210,26 @@ elseif(UNIX OR MINGW)

elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if(DNNL_TARGET_ARCH STREQUAL "AARCH64")
set(DEF_ARCH_OPT_FLAGS "-O3")
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
set(DEF_ARCH_OPT_FLAGS "-O3")
endif()
# For native compilation tune for the host processor
if (CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR)
append(DEF_ARCH_OPT_FLAGS "-mcpu=native")
endif()
elseif(DNNL_TARGET_ARCH STREQUAL "PPC64")
set(DEF_ARCH_OPT_FLAGS "-O3")
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
set(DEF_ARCH_OPT_FLAGS "-O3")
endif()
# In GCC, -ftree-vectorize is turned on under -O3 since 2007.
# For native compilation tune for the host processor
if (CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR)
append(DEF_ARCH_OPT_FLAGS "-mcpu=native")
endif()
elseif(DNNL_TARGET_ARCH STREQUAL "S390X")
set(DEF_ARCH_OPT_FLAGS "-O3")
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
set(DEF_ARCH_OPT_FLAGS "-O3")
endif()
# In GCC, -ftree-vectorize is turned on under -O3 since 2007.
# For native compilation tune for the host processor
if (CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR)
Expand Down

0 comments on commit 303256f

Please sign in to comment.