diff --git a/cmake/cross_compiling/postproject.cmake b/cmake/cross_compiling/postproject.cmake index b46af6a81b197f0c260499d7410bc5fbf44cc63f..89659b1e5fcf5e2c3dd01299661cf67092458d38 100644 --- a/cmake/cross_compiling/postproject.cmake +++ b/cmake/cross_compiling/postproject.cmake @@ -60,16 +60,11 @@ endfunction() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") if (LITE_ON_TINY_PUBLISH) if(NOT LITE_WITH_PYTHON) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions") - endif() - if(ARM_TARGET_LANG STREQUAL "clang") - # TODO(ysh329): add options for clang like gcc branch below - else() # ARM_TARGET_LANG STREQUAL "gcc" - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math -Ofast -Os -fomit-frame-pointer -fno-asynchronous-unwind-tables -fno-unwind-tables") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden -ffunction-sections") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden -ffunction-sections") - check_linker_flag(-Wl,--gc-sections) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions") endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math -Ofast -Os -fomit-frame-pointer -fno-asynchronous-unwind-tables -fno-unwind-tables") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden -ffunction-sections") + check_linker_flag(-Wl,--gc-sections) endif() if(LITE_WITH_OPENMP) diff --git a/lite/api/CMakeLists.txt b/lite/api/CMakeLists.txt index 55b032e08c35f8cbcb7484d45dcca360cadbddbb..5f4800fcbd0a10fc2ec4ec93bc6b9590ac75ff51 100644 --- a/lite/api/CMakeLists.txt +++ b/lite/api/CMakeLists.txt @@ -5,13 +5,8 @@ else() endif(LITE_WITH_LIGHT_WEIGHT_FRAMEWORK) if (LITE_ON_TINY_PUBLISH) - if(ARM_TARGET_LANG STREQUAL "clang") - set(CMAKE_CXX_FLAGS_RELEASE " -DNDEBUG") - set(CMAKE_C_FLAGS_RELEASE " -DNDEBUG") - else() # gcc - set(CMAKE_CXX_FLAGS_RELEASE "-Os -DNDEBUG") - set(CMAKE_C_FLAGS_RELEASE "-Os -DNDEBUG") - endif() + set(CMAKE_CXX_FLAGS_RELEASE "-Os -DNDEBUG") + set(CMAKE_C_FLAGS_RELEASE "-Os -DNDEBUG") endif() set(light_lib_DEPS light_api paddle_api paddle_api_light optimizer) if ((NOT LITE_ON_TINY_PUBLISH) AND (LITE_WITH_CUDA OR LITE_WITH_X86 OR ARM_TARGET_OS STREQUAL "android" OR ARM_TARGET_OS STREQUAL "armlinux")) @@ -50,11 +45,11 @@ else() if ((ARM_TARGET_OS STREQUAL "android") OR (ARM_TARGET_OS STREQUAL "armlinux")) add_library(paddle_light_api_shared SHARED "") target_sources(paddle_light_api_shared PUBLIC ${__lite_cc_files} paddle_api.cc light_api.cc light_api_impl.cc) - if(ARM_TARGET_LANG STREQUAL "clang") - set_target_properties(paddle_light_api_shared PROPERTIES COMPILE_FLAGS "") - else() # ARM_TARGET_LANG STREQUAL "gcc" - set_target_properties(paddle_light_api_shared PROPERTIES COMPILE_FLAGS "-flto -fdata-sections") + set(TARGET_COMIPILE_FLAGS "-fdata-sections") + if (NOT (ARM_TARGET_LANG STREQUAL "clang")) #gcc + set(TARGET_COMIPILE_FLAGS "${TARGET_COMIPILE_FLAGS} -flto") endif() + set_target_properties(paddle_light_api_shared PROPERTIES COMPILE_FLAGS "${TARGET_COMIPILE_FLAGS}") add_dependencies(paddle_light_api_shared op_list_h kernel_list_h) if (LITE_WITH_NPU) # Need to add HIAI runtime libs (libhiai.so) dependency diff --git a/lite/api/android/jni/native/CMakeLists.txt b/lite/api/android/jni/native/CMakeLists.txt index d9a684a75e95c63ae6fd15276e57e5e765c577a3..d46e9f7cdec1cf422340ff11165ee166c7520bab 100644 --- a/lite/api/android/jni/native/CMakeLists.txt +++ b/lite/api/android/jni/native/CMakeLists.txt @@ -1,13 +1,8 @@ # Generate paddle_lite_jni.so if (LITE_ON_TINY_PUBLISH) - if(ARM_TARGET_LANG STREQUAL "clang") - set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG") - set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG") - else() # ARM_TARGET_LANG STREQUAL "gcc" - set(CMAKE_CXX_FLAGS_RELEASE "-Os -DNDEBUG") - set(CMAKE_C_FLAGS_RELEASE "-Os -DNDEBUG") - endif() + set(CMAKE_CXX_FLAGS_RELEASE "-Os -DNDEBUG") + set(CMAKE_C_FLAGS_RELEASE "-Os -DNDEBUG") set(lib_DEPS light_api paddle_api paddle_api_light) else() set(lib_DEPS light_api cxx_api paddle_api_full paddle_api paddle_api_light) @@ -30,11 +25,11 @@ if (NOT LITE_ON_TINY_PUBLISH) endif() else() add_library(paddle_lite_jni SHARED "") - if(ARM_TARGET_LANG STREQUAL "clang") - set_target_properties(paddle_lite_jni PROPERTIES COMPILE_FLAGS "") - else() # ARM_TARGET_LANG STREQUAL "gcc" - set_target_properties(paddle_lite_jni PROPERTIES COMPILE_FLAGS "-flto -fdata-sections") + set(TARGET_COMIPILE_FLAGS "-fdata-sections") + if (NOT (ARM_TARGET_LANG STREQUAL "clang")) #gcc + set(TARGET_COMIPILE_FLAGS "${TARGET_COMIPILE_FLAGS} -flto") endif() + set_target_properties(paddle_lite_jni PROPERTIES COMPILE_FLAGS ${TARGET_COMIPILE_FLAGS}) target_sources(paddle_lite_jni PUBLIC ${__lite_cc_files} paddle_lite_jni.cc tensor_jni.cc) add_dependencies(paddle_lite_jni op_list_h kernel_list_h) if (LITE_WITH_NPU) diff --git a/lite/tools/build.sh b/lite/tools/build.sh index 930d401bda61e241ecb18a05a63b0a4e0d52b99c..c21f52ae40617329fb9e2e5209361344ee5110c8 100755 --- a/lite/tools/build.sh +++ b/lite/tools/build.sh @@ -390,13 +390,6 @@ function main { ;; --arm_lang=*) ARM_LANG="${i#*=}" - if [ ${ARM_LANG} == "clang" ]; then - set +x - echo - echo -e "error: only support gcc now, clang will be supported in future." - echo -# exit 1 - fi shift ;; --android_stl=*)