Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
bed331d8
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
bed331d8
编写于
6月 18, 2019
作者:
T
tensor-tang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support clang compile on arm
上级
48f09678
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
133 addition
and
50 deletion
+133
-50
CMakeLists.txt
CMakeLists.txt
+14
-1
cmake/cross_compiling/android.cmake
cmake/cross_compiling/android.cmake
+24
-1
cmake/cross_compiling/findar.cmake
cmake/cross_compiling/findar.cmake
+33
-0
cmake/external/gflags.cmake
cmake/external/gflags.cmake
+2
-1
cmake/external/glog.cmake
cmake/external/glog.cmake
+2
-1
cmake/external/gtest.cmake
cmake/external/gtest.cmake
+3
-1
cmake/external/protobuf.cmake
cmake/external/protobuf.cmake
+1
-0
paddle/fluid/lite/core/CMakeLists.txt
paddle/fluid/lite/core/CMakeLists.txt
+1
-1
paddle/fluid/lite/tools/build.sh
paddle/fluid/lite/tools/build.sh
+52
-44
paddle/fluid/lite/tools/mobile_readme.md
paddle/fluid/lite/tools/mobile_readme.md
+1
-0
未找到文件。
CMakeLists.txt
浏览文件 @
bed331d8
...
...
@@ -42,7 +42,17 @@ if(LITE_WITH_LIGHT_WEIGHT_FRAMEWORK)
message
(
FATAL_ERROR
"ARM_TARGET_ARCH_ABI must be in one of
${
ARM_TARGET_ARCH_ABI_LIST
}
"
)
endif
()
message
(
STATUS
"Lite ARM Compile
${
ARM_TARGET_OS
}
with
${
ARM_TARGET_ARCH_ABI
}
"
)
# check arch abi
if
(
NOT DEFINED ARM_TARGET_LANG
)
set
(
ARM_TARGET_LANG
"clang"
CACHE STRING
"Choose ARM Target Language"
)
endif
()
set
(
ARM_TARGET_LANG_LIST
"gcc"
"clang"
)
set_property
(
CACHE ARM_TARGET_LANG PROPERTY STRINGS
${
ARM_TARGET_LANG_LIST
}
)
if
(
NOT ARM_TARGET_LANG IN_LIST ARM_TARGET_LANG_LIST
)
message
(
FATAL_ERROR
"ARM_TARGET_LANG must be in one of
${
ARM_TARGET_LANG_LIST
}
"
)
endif
()
message
(
STATUS
"Lite ARM Compile
${
ARM_TARGET_OS
}
with
${
ARM_TARGET_ARCH_ABI
}
${
ARM_TARGET_LANG
}
"
)
include
(
cross_compiling/host
)
include
(
cross_compiling/armlinux
)
include
(
cross_compiling/android
)
...
...
@@ -158,6 +168,9 @@ include_directories("${PADDLE_SOURCE_DIR}")
# for mobile
if
(
WITH_LITE AND LITE_WITH_LIGHT_WEIGHT_FRAMEWORK
)
message
(
STATUS
"Building the mobile framework"
)
if
(
ANDROID
)
include
(
cross_compiling/findar
)
endif
()
# include the necessary thirdparty dependencies
include
(
external/gflags
)
# download, build, install gflags
include
(
external/glog
)
# download, build, install glog
...
...
cmake/cross_compiling/android.cmake
浏览文件 @
bed331d8
...
...
@@ -31,7 +31,7 @@ if(NOT DEFINED ANDROID_API_LEVEL)
endif
()
if
(
NOT DEFINED ANDROID_STL_TYPE
)
set
(
ANDROID_STL_TYPE
"c++_static"
CACHE STRING
"stl type"
)
set
(
ANDROID_STL_TYPE
"c++_static"
CACHE STRING
"stl type"
)
# can also use shared
endif
()
if
(
ARM_TARGET_ARCH_ABI STREQUAL
"armv7hf"
)
...
...
@@ -71,8 +71,31 @@ if (NOT ANDROID_STL_TYPE IN_LIST ANDROID_STL_TYPE_LITS)
message
(
FATAL_ERROR
"ANDROID_STL_TYPE must be in one of
${
ANDROID_STL_TYPE_LITS
}
"
)
endif
()
if
(
ARM_TARGET_LANG STREQUAL
"gcc"
)
# gcc do not need set lang
set
(
ARM_TARGET_LANG
""
)
endif
()
set
(
CMAKE_SYSTEM_NAME Android
)
set
(
CMAKE_SYSTEM_VERSION
${
ANDROID_API_LEVEL
}
)
set
(
CMAKE_ANDROID_ARCH_ABI
${
ANDROID_ARCH_ABI
}
)
set
(
CMAKE_ANDROID_NDK
${
ANDROID_NDK
}
)
set
(
CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION
${
ARM_TARGET_LANG
}
)
set
(
CMAKE_ANDROID_STL_TYPE
${
ANDROID_STL_TYPE
}
)
if
(
ARM_TARGET_LANG STREQUAL
"clang"
)
if
(
ARM_TARGET_ARCH_ABI STREQUAL
"armv8"
)
set
(
triple aarch64-v8a-linux-android
)
elseif
(
ARM_TARGET_ARCH_ABI STREQUAL
"armv7"
)
set
(
triple arm-v7a-linux-android
)
else
()
message
(
FATAL_ERROR
"Clang do not support this
${
ARM_TARGET_ARCH_ABI
}
, use armv8 or armv7"
)
endif
()
set
(
CMAKE_C_COMPILER clang
)
set
(
CMAKE_C_COMPILER_TARGET
${
triple
}
)
set
(
CMAKE_CXX_COMPILER clang++
)
set
(
CMAKE_CXX_COMPILER_TARGET
${
triple
}
)
message
(
STATUS
"CMAKE_CXX_COMPILER_TARGET:
${
CMAKE_CXX_COMPILER_TARGET
}
"
)
endif
()
cmake/cross_compiling/findar.cmake
0 → 100644
浏览文件 @
bed331d8
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
if
(
NOT ARM_TARGET_LANG STREQUAL
"clang"
)
# only clang need find ar tool
return
()
endif
()
if
(
NOT EXISTS
"
${
CMAKE_CXX_COMPILER
}
"
)
message
(
ERROR
"Can not find CMAKE_CXX_COMPILER
${
CMAKE_CXX_COMPILER
}
"
)
endif
()
get_filename_component
(
AR_PATH
${
CMAKE_CXX_COMPILER
}
PATH
)
find_file
(
AR_TOOL NAMES llvm-ar PATHS
${
AR_PATH
}
)
if
(
NOT AR_TOOL
)
message
(
ERROR
"Failed to find AR_TOOL in
${
AR_PATH
}
"
)
else
()
set
(
CMAKE_AR
${
AR_TOOL
}
)
message
(
STATUS
"Found CMAKE_AR : "
${
CMAKE_AR
}
)
endif
()
cmake/external/gflags.cmake
浏览文件 @
bed331d8
...
...
@@ -40,7 +40,8 @@ if(ANDROID)
"-DCMAKE_SYSTEM_VERSION=
${
CMAKE_SYSTEM_VERSION
}
"
"-DCMAKE_ANDROID_ARCH_ABI=
${
CMAKE_ANDROID_ARCH_ABI
}
"
"-DCMAKE_ANDROID_NDK=
${
CMAKE_ANDROID_NDK
}
"
"-DCMAKE_ANDROID_STL_TYPE=
${
CMAKE_ANDROID_STL_TYPE
}
"
)
"-DCMAKE_ANDROID_STL_TYPE=
${
CMAKE_ANDROID_STL_TYPE
}
"
"-DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=
${
CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION
}
"
)
endif
()
ExternalProject_Add
(
...
...
cmake/external/glog.cmake
浏览文件 @
bed331d8
...
...
@@ -46,7 +46,8 @@ if(ANDROID)
"-DCMAKE_SYSTEM_VERSION=
${
CMAKE_SYSTEM_VERSION
}
"
"-DCMAKE_ANDROID_ARCH_ABI=
${
CMAKE_ANDROID_ARCH_ABI
}
"
"-DCMAKE_ANDROID_NDK=
${
CMAKE_ANDROID_NDK
}
"
"-DCMAKE_ANDROID_STL_TYPE=
${
CMAKE_ANDROID_STL_TYPE
}
"
)
"-DCMAKE_ANDROID_STL_TYPE=
${
CMAKE_ANDROID_STL_TYPE
}
"
"-DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=
${
CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION
}
"
)
endif
()
ExternalProject_Add
(
...
...
cmake/external/gtest.cmake
浏览文件 @
bed331d8
...
...
@@ -58,7 +58,9 @@ IF(WITH_TESTING OR (WITH_DISTRIBUTE AND NOT WITH_GRPC))
"-DCMAKE_SYSTEM_VERSION=
${
CMAKE_SYSTEM_VERSION
}
"
"-DCMAKE_ANDROID_ARCH_ABI=
${
CMAKE_ANDROID_ARCH_ABI
}
"
"-DCMAKE_ANDROID_NDK=
${
CMAKE_ANDROID_NDK
}
"
"-DCMAKE_ANDROID_STL_TYPE=
${
CMAKE_ANDROID_STL_TYPE
}
"
)
"-DCMAKE_ANDROID_STL_TYPE=
${
CMAKE_ANDROID_STL_TYPE
}
"
"-DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=
${
CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION
}
"
)
endif
()
ExternalProject_Add
(
...
...
cmake/external/protobuf.cmake
浏览文件 @
bed331d8
...
...
@@ -199,6 +199,7 @@ FUNCTION(build_protobuf TARGET_NAME BUILD_FOR_HOST)
"-DCMAKE_ANDROID_ARCH_ABI=
${
CMAKE_ANDROID_ARCH_ABI
}
"
"-DCMAKE_ANDROID_NDK=
${
CMAKE_ANDROID_NDK
}
"
"-DCMAKE_ANDROID_STL_TYPE=
${
CMAKE_ANDROID_STL_TYPE
}
"
"-DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=
${
CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION
}
"
"-DCMAKE_CXX_COMPILER=
${
CMAKE_CXX_COMPILER
}
"
"-DCMAKE_C_COMPILER=
${
CMAKE_C_COMPILER
}
"
"-DCMAKE_C_FLAGS=
${
CMAKE_C_FLAGS
}
"
...
...
paddle/fluid/lite/core/CMakeLists.txt
浏览文件 @
bed331d8
if
(
WITH_TESTING
)
cc_library
(
lite_gtest_main SRCS lite_gtest_main.cc DEPS gtest
)
cc_library
(
lite_gtest_main SRCS lite_gtest_main.cc DEPS gtest
gflags
)
endif
()
lite_cc_library
(
target_wrapper_lite SRCS target_wrapper.cc
DEPS target_wrapper_host
...
...
paddle/fluid/lite/tools/build.sh
浏览文件 @
bed331d8
...
...
@@ -57,6 +57,7 @@ function check_style {
function
cmake_arm
{
# $1: ARM_TARGET_OS in "android" , "armlinux"
# $2: ARM_TARGET_ARCH_ABI in "armv8", "armv7" ,"armv7hf"
# $3: ARM_TARGET_LANG in "gcc" "clang"
cmake ..
\
-DWITH_GPU
=
OFF
\
-DWITH_MKL
=
OFF
\
...
...
@@ -66,7 +67,7 @@ function cmake_arm {
-DLITE_WITH_ARM
=
ON
\
-DLITE_WITH_LIGHT_WEIGHT_FRAMEWORK
=
ON
\
-DWITH_TESTING
=
ON
\
-DARM_TARGET_OS
=
$1
-DARM_TARGET_ARCH_ABI
=
$2
-DARM_TARGET_OS
=
$1
-DARM_TARGET_ARCH_ABI
=
$2
-DARM_TARGET_LANG
=
$3
}
function
build_single
{
...
...
@@ -125,31 +126,36 @@ function test_arm_android {
function
build_test_arm
{
# 1. Build goes first
cur_dir
=
$(
pwd
)
for
os
in
"android"
"armlinux"
;
do
for
abi
in
"armv8"
"armv7"
"armv7hf"
;
do
# TODO(hongming): enable compile armv7 and armv7hf on armlinux
if
[[
${
abi
}
==
"armv7hf"
]]
;
then
echo
"armv7hf is not supported on both android and armlinux yet"
for
lang
in
"gcc"
"clang"
;
do
for
os
in
"android"
"armlinux"
;
do
if
[[
${
os
}
==
"armlinux"
&&
${
lang
}
==
"clang"
]]
;
then
continue
fi
# TODO(hongming): enable armv7 on armlinux
if
[[
${
os
}
==
"armlinux"
&&
${
abi
}
==
"armv7"
]]
;
then
echo
"armv7 is not supported on armlinux yet"
continue
fi
if
[[
${
os
}
==
"android"
&&
${
abi
}
==
"armv7hf"
]]
;
then
echo
"android do not need armv7hf"
continue
fi
build_dir
=
$cur_dir
/build.lite.
${
os
}
.
${
abi
}
mkdir
-p
$build_dir
cd
$build_dir
cmake_arm
${
os
}
${
abi
}
build
$TESTS_FILE
for
abi
in
"armv8"
"armv7"
"armv7hf"
;
do
# TODO(hongming): enable compile armv7 and armv7hf on armlinux
if
[[
${
abi
}
==
"armv7hf"
]]
;
then
echo
"armv7hf is not supported on both android and armlinux yet"
continue
fi
# TODO(hongming): enable armv7 on armlinux
if
[[
${
os
}
==
"armlinux"
&&
${
abi
}
==
"armv7"
]]
;
then
echo
"armv7 is not supported on armlinux yet"
continue
fi
if
[[
${
os
}
==
"android"
&&
${
abi
}
==
"armv7hf"
]]
;
then
echo
"android do not need armv7hf"
continue
fi
build_dir
=
$cur_dir
/build.lite.
${
os
}
.
${
abi
}
.
${
lang
}
mkdir
-p
$build_dir
cd
$build_dir
cmake_arm
${
os
}
${
abi
}
${
lang
}
build
$TESTS_FILE
done
done
done
...
...
@@ -168,26 +174,28 @@ function build_test_arm {
sleep
1m
# now can only test android.
for
abi
in
"armv8"
"armv7"
;
do
# TODO(yuanshuai): enable armv7 on android
if
[[
${
abi
}
==
"armv7"
]]
;
then
continue
fi
build_dir
=
$cur_dir
/build.lite.android.
${
abi
}
cd
$build_dir
local
port
=
if
[[
${
abi
}
==
"armv7"
]]
;
then
port
=
${
port_armv7
}
fi
if
[[
${
abi
}
==
"armv8"
]]
;
then
port
=
${
port_armv8
}
fi
echo
"test file:
${
TESTS_FILE
}
"
for
_test
in
$(
cat
$TESTS_FILE
)
;
do
test_arm_android
$_test
$port
for
lang
in
"gcc"
"clang"
;
do
for
abi
in
"armv8"
"armv7"
;
do
# TODO(yuanshuai): enable armv7 on android
if
[[
${
abi
}
==
"armv7"
]]
;
then
continue
fi
build_dir
=
$cur_dir
/build.lite.android.
${
abi
}
.
${
lang
}
cd
$build_dir
local
port
=
if
[[
${
abi
}
==
"armv7"
]]
;
then
port
=
${
port_armv7
}
fi
if
[[
${
abi
}
==
"armv8"
]]
;
then
port
=
${
port_armv8
}
fi
echo
"test file:
${
TESTS_FILE
}
"
for
_test
in
$(
cat
$TESTS_FILE
)
;
do
test_arm_android
$_test
$port
done
done
done
...
...
paddle/fluid/lite/tools/mobile_readme.md
浏览文件 @
bed331d8
...
...
@@ -26,6 +26,7 @@ $ git checkout incubate/lite
-
"armv8", 等效于 "arm64"。 default值为这个。
-
"armv7hf", 等效于使用
`eabihf`
且
`-march=armv7-a -mfloat-abi=hard -mfpu=neon-vfpv4 `
。
-
"armv7", 等效于使用
`eabi`
且
`-march=armv7-a -mfloat-abi=softfp -mfpu=neon-vfpv4`
。
-
`ARM_TARGET_LANG`
代表目标编译的语言, 默认为gcc,支持 gcc和clang两种。
### 编译
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录