From ce5a40b1984803213f97dbd2d6b64ebbf2b0557c Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=98=A4=ED=98=95=EC=84=9D/On-Device=20Lab=28SR=29/Staff?= =?utf8?q?=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Thu, 14 Nov 2019 19:06:31 +0900 Subject: [PATCH] [runtime/gbs] Fix coverage build (#8940) - Update build type setting for test (coverage) build - Move optimization level setting to ApplyCompileFlags.cmake - Optimization level and debug setting in target_compile_option is not working - COVERAGE_BUILD is not used any more Signed-off-by: Hyeongseok Oh --- infra/nnfw/CMakeLists.txt | 11 ++++++----- infra/nnfw/cmake/ApplyCompileFlags.cmake | 10 ++++++++-- infra/nnfw/cmake/buildtool/config/config_linux.cmake | 14 -------------- packaging/nnfw.spec | 4 ++-- 4 files changed, 16 insertions(+), 23 deletions(-) diff --git a/infra/nnfw/CMakeLists.txt b/infra/nnfw/CMakeLists.txt index 5858e94..8692e91 100644 --- a/infra/nnfw/CMakeLists.txt +++ b/infra/nnfw/CMakeLists.txt @@ -61,10 +61,6 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # note: this should be placed before flags and options setting nnas_include(IdentifyPlatform) -# apply compilation flags -# note: this should be placed after cmake/option/option_xxx.cmake files -include("cmake/ApplyCompileFlags.cmake") - # Configuration flags include("cmake/CfgOptionFlags.cmake") # and besides CfgOptionFlags.cmake that can be given outside @@ -73,6 +69,11 @@ include("cmake/CfgOptionFlags.cmake") # TARGET_ARCH: target architecture string for cross building # TARGET_OS: target os string for cross building +# apply compilation flags +# NOTE This should be placed after cmake/CfgOptionFlags.cmake files include +# because compile flag setting can be decided using option (ex. ENABLE_COVERAGE) +include("cmake/ApplyCompileFlags.cmake") + nnfw_find_package(GTest QUIET) option(ENABLE_TEST "Build Tests using Google Test" ${GTest_FOUND}) @@ -94,7 +95,7 @@ endif(ENABLE_STRICT_BUILD) # to link nnfw_coverage on each module which want to check coverage add_library(nnfw_coverage INTERFACE) if(ENABLE_COVERAGE) - target_compile_options(nnfw_coverage INTERFACE -g -O -DDEBUG -fprofile-arcs -ftest-coverage) + target_compile_options(nnfw_coverage INTERFACE -fprofile-arcs -ftest-coverage) target_link_libraries(nnfw_coverage INTERFACE gcov) endif(ENABLE_COVERAGE) diff --git a/infra/nnfw/cmake/ApplyCompileFlags.cmake b/infra/nnfw/cmake/ApplyCompileFlags.cmake index 5098fd0..956ddfe 100644 --- a/infra/nnfw/cmake/ApplyCompileFlags.cmake +++ b/infra/nnfw/cmake/ApplyCompileFlags.cmake @@ -2,8 +2,14 @@ # Platform independent compile flag setting # # flags for build type: debug, release -set(CMAKE_C_FLAGS_DEBUG "-O0 -g -DDEBUG") -set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -DDEBUG") +if(${ENABLE_COVERAGE}) + # test-coverage build flag for tizen + set(CMAKE_C_FLAGS_DEBUG "-O -g -DDEBUG") + set(CMAKE_CXX_FLAGS_DEBUG "-O -g -DDEBUG") +else(${ENABLE_COVERAGE}) + set(CMAKE_C_FLAGS_DEBUG "-O0 -g -DDEBUG") + set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -DDEBUG") +endif(${ENABLE_COVERAGE}) set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG") set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") diff --git a/infra/nnfw/cmake/buildtool/config/config_linux.cmake b/infra/nnfw/cmake/buildtool/config/config_linux.cmake index a56dec0..9bf646f 100644 --- a/infra/nnfw/cmake/buildtool/config/config_linux.cmake +++ b/infra/nnfw/cmake/buildtool/config/config_linux.cmake @@ -2,20 +2,6 @@ # linux common compile options # -# test-coverage build flag -if("${COVERAGE_BUILD}" STREQUAL "1") - set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE ON) - set(FLAGS_COMMON "${FLAGS_COMMON} -fprofile-arcs -ftest-coverage") - set(CMAKE_EXE_LINKER_FLAGS - "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage") - set(CMAKE_C_FLAGS_DEBUG "-O -g -DDEBUG") - set(CMAKE_CXX_FLAGS_DEBUG "-O -g -DDEBUG") -endif() - -# -# linux common variable and settings -# - # remove warning from arm cl # https://github.com/ARM-software/ComputeLibrary/issues/330 set(GCC_VERSION_DISABLE_WARNING 6.0) diff --git a/packaging/nnfw.spec b/packaging/nnfw.spec index b03982d..39a3937 100644 --- a/packaging/nnfw.spec +++ b/packaging/nnfw.spec @@ -77,10 +77,10 @@ NNFW test rpm. It does not depends on nnfw rpm since it contains nnfw runtime. %define test_suite_list infra/scripts tests/scripts tests/framework %if %{coverage_build} == 1 %define coverage_option -DENABLE_COVERAGE=ON -%define build_type Debug +%define test_build_type Debug %endif %define test_build_env NNFW_INSTALL_PREFIX=%{test_install_path} NNFW_WORKSPACE=build_for_test -%define test_build_options %{coverage_option} -DCMAKE_BUILD_TYPE=%{build_type} -DTARGET_ARCH=%{target_arch} -DTARGET_OS=tizen -DENVVAR_NEURUN_CONFIG=ON +%define test_build_options %{coverage_option} -DCMAKE_BUILD_TYPE=%{test_build_type} -DTARGET_ARCH=%{target_arch} -DTARGET_OS=tizen -DENVVAR_NEURUN_CONFIG=ON %prep %setup -q -- 2.7.4