diff --git a/cmake/cross_compiling/postproject.cmake b/cmake/cross_compiling/postproject.cmake index 7466b3e6d438277ad31020f76665bf689df436f5..b46af6a81b197f0c260499d7410bc5fbf44cc63f 100644 --- a/cmake/cross_compiling/postproject.cmake +++ b/cmake/cross_compiling/postproject.cmake @@ -60,11 +60,16 @@ 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") + 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) 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 bce6938c890580f2cc84f82e4238878ba1efafe5..55b032e08c35f8cbcb7484d45dcca360cadbddbb 100644 --- a/lite/api/CMakeLists.txt +++ b/lite/api/CMakeLists.txt @@ -5,8 +5,13 @@ else() endif(LITE_WITH_LIGHT_WEIGHT_FRAMEWORK) if (LITE_ON_TINY_PUBLISH) - set(CMAKE_CXX_FLAGS_RELEASE "-Os -DNDEBUG") - set(CMAKE_C_FLAGS_RELEASE "-Os -DNDEBUG") + 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() 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")) @@ -45,7 +50,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) - set_target_properties(paddle_light_api_shared PROPERTIES COMPILE_FLAGS "-flto -fdata-sections") + 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") + endif() 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 c1766772f8aaa417c3da1d72f2692c10c10194b4..d9a684a75e95c63ae6fd15276e57e5e765c577a3 100644 --- a/lite/api/android/jni/native/CMakeLists.txt +++ b/lite/api/android/jni/native/CMakeLists.txt @@ -1,8 +1,13 @@ # Generate paddle_lite_jni.so if (LITE_ON_TINY_PUBLISH) - set(CMAKE_CXX_FLAGS_RELEASE "-Os -DNDEBUG") - set(CMAKE_C_FLAGS_RELEASE "-Os -DNDEBUG") + 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(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) @@ -25,7 +30,11 @@ if (NOT LITE_ON_TINY_PUBLISH) endif() else() add_library(paddle_lite_jni SHARED "") - set_target_properties(paddle_lite_jni PROPERTIES COMPILE_FLAGS "-flto -fdata-sections") + 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") + endif() 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 8bcfea06ba5dad2bbf12cf90d114383cdcaa4ff1..930d401bda61e241ecb18a05a63b0a4e0d52b99c 100755 --- a/lite/tools/build.sh +++ b/lite/tools/build.sh @@ -395,7 +395,7 @@ function main { echo echo -e "error: only support gcc now, clang will be supported in future." echo - exit 1 +# exit 1 fi shift ;;