@@ -84,19 +84,15 @@ else()
84
84
add_library (paddle_api_light_bundled STATIC $< TARGET_OBJECTS:PADDLELITE_OBJS> )
85
85
else ()
86
86
# 1. enable -flto compiling flag if toochain==gcc
87
- set (TARGET_COMIPILE_FLAGS "-fdata-sections" )
88
- if (NOT (ARM_TARGET_LANG STREQUAL "clang" )) #gcc
89
- set (TARGET_COMIPILE_FLAGS "${TARGET_COMIPILE_FLAGS} -flto" )
90
- # '-flto' is only supported by gcc-ar, while gcc-ar is not supported on MacOs
91
- if (NOT ${HOST_SYSTEM} MATCHES "macosx" )
92
- SET (CMAKE_AR "gcc-ar" )
93
- SET (CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> qcs <TARGET> <LINK_FLAGS> <OBJECTS>" )
94
- SET (CMAKE_CXX_ARCHIVE_FINISH true )
95
- endif ()
96
- # TODO (hong19860320): Disable lto temporarily since it causes fail to catch the exceptions in android when toolchain is gcc.
87
+ # TODO (hong19860320): Disable lto temporarily since it causes fail to catch the exceptions in android when toolchain is gcc.
88
+ if (NOT (ARM_TARGET_LANG STREQUAL "clang" ))
97
89
if (ARM_TARGET_OS STREQUAL "android" AND LITE_WITH_EXCEPTION )
98
90
set (TARGET_COMIPILE_FLAGS "" )
91
+ else ()
92
+ set (TARGET_COMIPILE_FLAGS "-fdata-sections -flto" )
99
93
endif ()
94
+ else ()
95
+ set (TARGET_COMIPILE_FLAGS "-fdata-sections" )
100
96
endif ()
101
97
# 1.1 enable -flto on PADDLELITE_OBJS
102
98
set_target_properties (PADDLELITE_OBJS PROPERTIES COMPILE_FLAGS "${TARGET_COMIPILE_FLAGS} " )
@@ -130,11 +126,11 @@ else()
130
126
endif ()
131
127
132
128
# 4. produce static lib `libpaddle_api_light_bundled.a` from `PADDLELITE_OBJS`
133
- # '-flto' is only supported by gcc-ar, while gcc-ar is not supported on MacOs
134
- if (NOT ${HOST_SYSTEM} MATCHES "macosx" )
135
- add_library (paddle_api_light_bundled STATIC $< TARGET_OBJECTS:PADDLELITE_OBJS> )
136
- else ()
129
+ # '-flto' is only supported by dynamic lib
130
+ if (TARGET_COMIPILE_FLAGS MATCHES ".*-flto.*" )
137
131
add_library (paddle_api_light_bundled STATIC ${__lite_cc_files} paddle_api.cc light_api.cc light_api_impl.cc )
132
+ else ()
133
+ add_library (paddle_api_light_bundled STATIC $< TARGET_OBJECTS:PADDLELITE_OBJS> )
138
134
endif ()
139
135
endif ()
140
136
endif ()
0 commit comments