提交 3009f36a 编写于 作者: L Liangliang He

Add Linaro ARM Linux cross compiling toolchain

上级 91e9b208
......@@ -73,6 +73,7 @@ platform_compatible_tests:
stage: platform_compatible_tests
script:
- bazel build mace/core:core --define openmp=true
- bazel build --config aarch64_linux --define openmp=true --define opencl=true --define neon=true //mace/libmace:libmace.so
build_libraries:
stage: build_libraries
......
......@@ -4,8 +4,9 @@ workspace(name = "mace")
load("//repository/git:git_configure.bzl", "git_version_repository")
load("//repository/opencl-kernel:opencl_kernel_configure.bzl", "encrypt_opencl_kernel_repository")
git_version_repository(name="local_version_config")
encrypt_opencl_kernel_repository(name="local_opencl_kernel_encrypt")
git_version_repository(name = "local_version_config")
encrypt_opencl_kernel_repository(name = "local_opencl_kernel_encrypt")
# proto_library rules implicitly depend on @com_google_protobuf//:protoc,
# which is the proto-compiler.
......@@ -138,3 +139,26 @@ android_ndk_repository(
# Android 5.0
api_level = 21,
)
# Set up default cross compilers for arm linux
new_http_archive(
name = "gcc_linaro_7_3_1_arm_linux_gnueabihf",
build_file = "third_party/compilers/arm_compiler.BUILD",
sha256 = "7248bf105d0d468887a9b8a7120bb281ac8ad0223d9cb3d00dc7c2d498485d91",
strip_prefix = "gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf",
urls = [
"https://cnbj1.fds.api.xiaomi.com/mace/third-party/gcc-linaro/gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf.tar.xz",
"https://releases.linaro.org/components/toolchain/binaries/latest/arm-linux-gnueabihf/gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf.tar.xz",
],
)
new_http_archive(
name = "gcc_linaro_7_3_1_aarch64_linux_gnu",
build_file = "third_party/compilers/aarch64_compiler.BUILD",
sha256 = "73eed74e593e2267504efbcf3678918bb22409ab7afa3dc7c135d2c6790c2345",
strip_prefix = "gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu",
urls = [
"https://cnbj1.fds.api.xiaomi.com/mace/third-party/gcc-linaro/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz",
"https://releases.linaro.org/components/toolchain/binaries/latest/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz",
],
)
......@@ -104,7 +104,7 @@ cc_library(
"-Werror",
"-Wextra",
"-Wno-missing-field-initializers",
] + if_opencl_enabled([
] + if_openmp_enabled(["-fopenmp"]) + if_opencl_enabled([
"-DMACE_ENABLE_OPENCL",
]),
deps = [
......
......@@ -53,7 +53,6 @@ void Benchmark::Run(const char *pattern) {
// Compute name width.
int width = 10;
char name[100];
std::smatch match;
for (auto b : *all_benchmarks) {
if (!std::regex_match(b->name_, match, regex)) continue;
......
......@@ -811,7 +811,7 @@ void SGemm::RunPerBatch(const float *lhs_data,
// d: remain
for (index_t d = 0; d < remain_d; ++d) {
// 4.1.1
float32x4_t b0, b1;
float32x4_t b0;
float32x2_t a0 = vdup_n_f32(rhs_ptr[0]);
b0 = vld1q_f32(lhs_ptr);
......
......@@ -291,7 +291,6 @@ void TestComplexDeconvNxNS12(const int batch,
auto func = [&](int kernel_h, int kernel_w, int stride_h, int stride_w,
Padding type, int padding) {
// generate random input
static unsigned int seed = time(NULL);
int height = shape[0];
int width = shape[1];
int input_channels = shape[2];
......
......@@ -245,7 +245,6 @@ class OpsTestNet {
output->Resize(input_shape);
Tensor::MappingGuard input_guard(input);
const T *input_data = input->data<T>();
output->CopyBytes(input->raw_data(), input->size() * input->SizeOfType());
}
......
......@@ -54,8 +54,6 @@ void TestQuantizeDequantize(const std::vector<float> &input, bool non_zero) {
net.RunOp();
auto output = net.GetTensor("Output");
ExpectTensorNear<float>(*net.GetTensor("Input"),
*net.GetTensor("Output"),
0.1);
......
package(default_visibility = ['//visibility:public'])
filegroup(
name = 'gcc',
srcs = [
'bin/aarch64-linux-gnu-gcc',
],
)
filegroup(
name = 'ar',
srcs = [
'bin/aarch64-linux-gnu-ar',
],
)
filegroup(
name = 'ld',
srcs = [
'bin/aarch64-linux-gnu-ld',
],
)
filegroup(
name = 'nm',
srcs = [
'bin/aarch64-linux-gnu-nm',
],
)
filegroup(
name = 'objcopy',
srcs = [
'bin/aarch64-linux-gnu-objcopy',
],
)
filegroup(
name = 'objdump',
srcs = [
'bin/aarch64-linux-gnu-objdump',
],
)
filegroup(
name = 'strip',
srcs = [
'bin/aarch64-linux-gnu-strip',
],
)
filegroup(
name = 'as',
srcs = [
'bin/aarch64-linux-gnu-as',
],
)
filegroup(
name = "compiler_pieces",
srcs = glob([
"aarch64-linux-gnu/**",
"libexec/**",
"lib/gcc/aarch64-linux-gnu/**",
"include/**",
]),
)
filegroup(
name = "compiler_components",
srcs = [
":ar",
":as",
":gcc",
":ld",
":nm",
":objcopy",
":objdump",
":strip",
],
)
package(default_visibility = ["//visibility:public"])
filegroup(
name = "gcc",
srcs = [
"bin/arm-linux-gnueabihf-gcc",
],
)
filegroup(
name = "ar",
srcs = [
"bin/arm-linux-gnueabihf-ar",
],
)
filegroup(
name = "ld",
srcs = [
"bin/arm-linux-gnueabihf-ld",
],
)
filegroup(
name = "nm",
srcs = [
"bin/arm-linux-gnueabihf-nm",
],
)
filegroup(
name = "objcopy",
srcs = [
"bin/arm-linux-gnueabihf-objcopy",
],
)
filegroup(
name = "objdump",
srcs = [
"bin/arm-linux-gnueabihf-objdump",
],
)
filegroup(
name = "strip",
srcs = [
"bin/arm-linux-gnueabihf-strip",
],
)
filegroup(
name = "as",
srcs = [
"bin/arm-linux-gnueabihf-as",
],
)
filegroup(
name = "compiler_pieces",
srcs = glob([
"arm-linux-gnueabihf/**",
"libexec/**",
"lib/gcc/arm-linux-gnueabihf/**",
"include/**",
]),
)
filegroup(
name = "compiler_components",
srcs = [
":ar",
":as",
":gcc",
":ld",
":nm",
":objcopy",
":objdump",
":strip",
],
)
# This is the entry point for --crosstool_top. Toolchains are found
# by lopping off the name of --crosstool_top and searching for
# 'cc-compiler-${CPU}' in this BUILD file, where CPU is the target CPU
# specified in --cpu.
#
# This file group should include
# * all cc_toolchain targets supported
# * all file groups that said cc_toolchain might refer to,
# including the default_grte_top setting in the CROSSTOOL
# protobuf.
filegroup(
name = "toolchain_fg",
srcs = [
":cc-compiler-aarch64",
":linaro_linux_all_files",
"@gcc_linaro_7_3_1_aarch64_linux_gnu//:compiler_components",
],
)
filegroup(
name = "srcs",
srcs = glob(["**"]) + [
"//tools/aarch64_compiler/linaro_linux_gcc:srcs",
],
visibility = ["//visibility:public"],
)
cc_toolchain_suite(
name = "toolchain",
# target_cpu | compiler
toolchains = {
"aarch64|gcc": "cc-compiler-aarch64",
},
)
filegroup(
name = "linaro_linux_all_files",
srcs = [
"//tools/aarch64_compiler/linaro_linux_gcc:tool-wrappers",
"@gcc_linaro_7_3_1_aarch64_linux_gnu//:compiler_pieces",
],
)
filegroup(
name = "linaro_linux_linker_files",
srcs = [
"//tools/aarch64_compiler/linaro_linux_gcc:ar",
"//tools/aarch64_compiler/linaro_linux_gcc:gcc",
"//tools/aarch64_compiler/linaro_linux_gcc:ld",
"@gcc_linaro_7_3_1_aarch64_linux_gnu//:compiler_pieces",
],
)
filegroup(
name = "linaro_linux_compiler_files",
srcs = [
"//tools/aarch64_compiler/linaro_linux_gcc:as",
"//tools/aarch64_compiler/linaro_linux_gcc:gcc",
"//tools/aarch64_compiler/linaro_linux_gcc:ld",
],
)
filegroup(
name = "empty",
srcs = [],
)
cc_toolchain(
name = "cc-compiler-aarch64",
all_files = ":linaro_linux_all_files",
compiler_files = ":linaro_linux_compiler_files",
cpu = "aarch64",
dwp_files = ":empty",
dynamic_runtime_libs = [":empty"],
linker_files = ":linaro_linux_linker_files",
objcopy_files = "//tools/aarch64_compiler/linaro_linux_gcc:objcopy",
static_runtime_libs = [":empty"],
strip_files = "//tools/aarch64_compiler/linaro_linux_gcc:strip",
supports_param_files = 1,
visibility = ["//visibility:public"],
)
major_version: "local"
minor_version: ""
default_target_cpu: "aarch64"
default_toolchain {
cpu: "aarch64"
toolchain_identifier: "aarch64-linux-gnu"
}
toolchain {
abi_version: "gcc"
abi_libc_version: ""
builtin_sysroot: ""
compiler: "gcc"
host_system_name: "aarch64"
needsPic: true
supports_gold_linker: false
supports_incremental_linker: false
supports_fission: false
supports_interface_shared_objects: false
supports_normalizing_ar: true
supports_start_end_lib: false
supports_thin_archives: true
target_libc: ""
target_cpu: "aarch64"
target_system_name: ""
toolchain_identifier: "aarch64-linux-gnu"
tool_path { name: "ar" path: "linaro_linux_gcc/aarch64-linux-gnu-ar" }
tool_path { name: "compat-ld" path: "linaro_linux_gcc/aarch64-linux-gnu-ld" }
tool_path { name: "cpp" path: "linaro_linux_gcc/aarch64-linux-gnu-gcc" }
tool_path { name: "dwp" path: "linaro_linux_gcc/aarch64-linux-gnu-dwp" }
tool_path { name: "gcc" path: "linaro_linux_gcc/aarch64-linux-gnu-gcc" }
tool_path { name: "gcov" path: "linaro_linux_gcc/aarch64-linux-gnu-gcov" }
# C(++) compiles invoke the compiler (as that is the one knowing where
# to find libraries), but we provide LD so other rules can invoke the linker.
tool_path { name: "ld" path: "linaro_linux_gcc/aarch64-linux-gnu-ld" }
tool_path { name: "nm" path: "linaro_linux_gcc/aarch64-linux-gnu-nm" }
tool_path { name: "objcopy" path: "linaro_linux_gcc/aarch64-linux-gnu-objcopy" }
objcopy_embed_flag: "-I"
objcopy_embed_flag: "binary"
tool_path { name: "objdump" path: "linaro_linux_gcc/aarch64-linux-gnu-objdump" }
tool_path { name: "strip" path: "linaro_linux_gcc/aarch64-linux-gnu-strip" }
compiler_flag: "--sysroot=external/gcc_linaro_7_3_1_aarch64_linux_gnu/aarch64-linux-gnu/libc"
cxx_flag: "-isystem"
cxx_flag: "external/gcc_linaro_7_3_1_aarch64_linux_gnu/aarch64-linux-gnu/include/c++/7.3.1/aarch64-linux-gnu"
cxx_flag: "-isystem"
cxx_flag: "external/gcc_linaro_7_3_1_aarch64_linux_gnu/aarch64-linux-gnu/include/c++/7.3.1"
cxx_flag: "-isystem"
cxx_flag: "external/gcc_linaro_7_3_1_aarch64_linux_gnu/include/c++/7.3.1/aarch64-linux-gnu"
cxx_flag: "-isystem"
cxx_flag: "external/gcc_linaro_7_3_1_aarch64_linux_gnu/include/c++/7.3.1"
cxx_builtin_include_directory: "%package(@gcc_linaro_7_3_1_aarch64_linux_gnu//include)%"
cxx_builtin_include_directory: "%package(@gcc_linaro_7_3_1_aarch64_linux_gnu//aarch64-linux-gnu/libc/usr/include)%"
cxx_builtin_include_directory: "%package(@gcc_linaro_7_3_1_aarch64_linux_gnu//aarch64-linux-gnu/libc/usr/lib/include)%"
cxx_builtin_include_directory: "%package(@gcc_linaro_7_3_1_aarch64_linux_gnu//aarch64-linux-gnu/libc/lib/gcc/aarch64-linux-gnu/7.3.1/include-fixed)%"
cxx_builtin_include_directory: "%package(@gcc_linaro_7_3_1_aarch64_linux_gnu//include)%/c++/7.3.1"
cxx_builtin_include_directory: "%package(@gcc_linaro_7_3_1_aarch64_linux_gnu//aarch64-linux-gnu/libc/lib/gcc/aarch64-linux-gnu/7.3.1/include)%"
cxx_builtin_include_directory: "%package(@gcc_linaro_7_3_1_aarch64_linux_gnu//aarch64-linux-gnu/libc/lib/gcc/aarch64-linux-gnu/7.3.1/include-fixed)%"
cxx_builtin_include_directory: "%package(@gcc_linaro_7_3_1_aarch64_linux_gnu//lib/gcc/aarch64-linux-gnu/7.3.1/include)%"
cxx_builtin_include_directory: "%package(@gcc_linaro_7_3_1_aarch64_linux_gnu//lib/gcc/aarch64-linux-gnu/7.3.1/include-fixed)%"
cxx_builtin_include_directory: "%package(@gcc_linaro_7_3_1_aarch64_linux_gnu//aarch64-linux-gnu/include)%/c++/7.3.1"
linker_flag: "--sysroot=external/gcc_linaro_7_3_1_aarch64_linux_gnu/aarch64-linux-gnu/libc"
linker_flag: "-fuse-ld=gold"
linker_flag: "-Wl,-no-as-needed"
linker_flag: "-lstdc++"
linker_flag: "-latomic"
linker_flag: "-lm"
linker_flag: "-lpthread"
# Anticipated future default.
# This makes GCC and Clang do what we want when called through symlinks.
unfiltered_cxx_flag: "-no-canonical-prefixes"
linker_flag: "-no-canonical-prefixes"
# Make C++ compilation deterministic. Use linkstamping instead of these
# compiler symbols.
unfiltered_cxx_flag: "-Wno-builtin-macro-redefined"
unfiltered_cxx_flag: "-D__DATE__=\"redacted\""
unfiltered_cxx_flag: "-D__TIMESTAMP__=\"redacted\""
unfiltered_cxx_flag: "-D__TIME__=\"redacted\""
# Security hardening on by default.
# Conservative choice; -D_FORTIFY_SOURCE=2 may be unsafe in some cases.
# We need to undef it before redefining it as some distributions now have
# it enabled by default.
compiler_flag: "-U_FORTIFY_SOURCE"
compiler_flag: "-fstack-protector"
compiler_flag: "-fPIE"
linker_flag: "-v"
linker_flag: "-pie"
linker_flag: "-Wl,-z,relro,-z,now"
# Enable coloring even if there's no attached terminal. Bazel removes the
# escape sequences if --nocolor is specified.
compiler_flag: "-fdiagnostics-color=always"
# All warnings are enabled. Maybe enable -Werror as well?
compiler_flag: "-Wall"
# Enable a few more warnings that aren't part of -Wall.
compiler_flag: "-Wunused-but-set-parameter"
# But disable some that are problematic.
compiler_flag: "-Wno-free-nonheap-object" # has false positives
# Keep stack frames for debugging, even in opt mode.
compiler_flag: "-fno-omit-frame-pointer"
# Stamp the binary with a unique identifier.
linker_flag: "-Wl,--build-id=md5"
linker_flag: "-Wl,--hash-style=gnu"
compilation_mode_flags {
mode: DBG
# Enable debug symbols.
compiler_flag: "-g"
}
compilation_mode_flags {
mode: OPT
# No debug symbols.
# Maybe we should enable https://gcc.gnu.org/wiki/DebugFission for opt or
# even generally? However, that can't happen here, as it requires special
# handling in Bazel.
compiler_flag: "-g0"
# Conservative choice for -O
# -O3 can increase binary size and even slow down the resulting binaries.
# Profile first and / or use FDO if you need better performance than this.
compiler_flag: "-O2"
# Disable assertions
compiler_flag: "-DNDEBUG"
# Removal of unused code and data at link time (can this increase binary size in some cases?).
compiler_flag: "-ffunction-sections"
compiler_flag: "-fdata-sections"
linker_flag: "-Wl,--gc-sections"
}
}
package(default_visibility = ["//tools/aarch64_compiler:__pkg__"])
filegroup(
name = "srcs",
srcs = glob(["**"]),
visibility = ["//visibility:public"],
)
filegroup(
name = "gcc",
srcs = [
"aarch64-linux-gnu-gcc",
"@gcc_linaro_7_3_1_aarch64_linux_gnu//:gcc",
],
)
filegroup(
name = "ar",
srcs = [
"aarch64-linux-gnu-ar",
"@gcc_linaro_7_3_1_aarch64_linux_gnu//:ar",
],
)
filegroup(
name = "ld",
srcs = [
"aarch64-linux-gnu-ld",
"@gcc_linaro_7_3_1_aarch64_linux_gnu//:ld",
],
)
filegroup(
name = "nm",
srcs = [
"aarch64-linux-gnu-nm",
"@gcc_linaro_7_3_1_aarch64_linux_gnu//:nm",
],
)
filegroup(
name = "objcopy",
srcs = [
"aarch64-linux-gnu-objcopy",
"@gcc_linaro_7_3_1_aarch64_linux_gnu//:objcopy",
],
)
filegroup(
name = "objdump",
srcs = [
"aarch64-linux-gnu-objdump",
"@gcc_linaro_7_3_1_aarch64_linux_gnu//:objdump",
],
)
filegroup(
name = "strip",
srcs = [
"aarch64-linux-gnu-strip",
"@gcc_linaro_7_3_1_aarch64_linux_gnu//:strip",
],
)
filegroup(
name = "as",
srcs = [
"aarch64-linux-gnu-as",
"@gcc_linaro_7_3_1_aarch64_linux_gnu//:as",
],
)
filegroup(
name = "tool-wrappers",
srcs = [
":ar",
":as",
":gcc",
":ld",
":nm",
":objcopy",
":objdump",
":strip",
],
)
#!/bin/bash --norc
exec -a aarch64-linux-gnu-ar \
external/gcc_linaro_7_3_1_aarch64_linux_gnu/bin/aarch64-linux-gnu-ar \
"$@"
#!/bin/bash --norc
exec -a aarch64-linux-gnu-as \
external/gcc_linaro_7_3_1_aarch64_linux_gnu/bin/aarch64-linux-gnu-as \
"$@"
#!/bin/bash --norc
PATH="external/gcc_linaro_7_3_1_aarch64_linux_gnu/libexec/gcc/aarch64-linux-gnu/7.3.1:$PATH" \
exec \
external/gcc_linaro_7_3_1_aarch64_linux_gnu/bin/aarch64-linux-gnu-gcc \
"$@"
#!/bin/bash --norc
exec -a aarch64-linux-gnu-gcov \
external/gcc_linaro_7_3_1_aarch64_linux_gnu/bin/aarch64-linux-gnu-gcov \
"$@"
#!/bin/bash --norc
exec -a aarch64-linux-gnu-ld \
external/gcc_linaro_7_3_1_aarch64_linux_gnu/bin/aarch64-linux-gnu-ld \
"$@"
#!/bin/bash --norc
exec -a aarch64-linux-gnu-nm \
external/gcc_linaro_7_3_1_aarch64_linux_gnu/bin/aarch64-linux-gnu-nm \
"$@"
#!/bin/bash --norc
exec -a aarch64-linux-gnu-objcopy \
external/gcc_linaro_7_3_1_aarch64_linux_gnu/bin/aarch64-linux-gnu-objcopy \
"$@"
#!/bin/bash --norc
exec -a aarch64-linux-gnu-objdump \
external/gcc_linaro_7_3_1_aarch64_linux_gnu/bin/aarch64-linux-gnu-objdump \
"$@"
#!/bin/bash --norc
exec -a aarch64-linux-gnu-strip \
external/gcc_linaro_7_3_1_aarch64_linux_gnu/bin/aarch64-linux-gnu-strip \
"$@"
# This is the entry point for --crosstool_top. Toolchains are found
# by lopping off the name of --crosstool_top and searching for
# 'cc-compiler-${CPU}' in this BUILD file, where CPU is the target CPU
# specified in --cpu.
#
# This file group should include
# * all cc_toolchain targets supported
# * all file groups that said cc_toolchain might refer to,
# including the default_grte_top setting in the CROSSTOOL
# protobuf.
filegroup(
name = "toolchain_fg",
srcs = [
":cc-compiler-armeabi-v7a",
":linaro_linux_all_files",
"@gcc_linaro_7_3_1_arm_linux_gnueabihf//:compiler_components",
],
)
filegroup(
name = "srcs",
srcs = glob(["**"]) + [
"//tools/arm_compiler/linaro_linux_gcc:srcs",
],
visibility = ["//visibility:public"],
)
cc_toolchain_suite(
name = "toolchain",
# target_cpu | compiler
toolchains = {
"armeabi-v7a|gcc": "cc-compiler-armeabi-v7a",
},
)
filegroup(
name = "linaro_linux_all_files",
srcs = [
"//tools/arm_compiler/linaro_linux_gcc:tool-wrappers",
"@gcc_linaro_7_3_1_arm_linux_gnueabihf//:compiler_pieces",
],
)
filegroup(
name = "linaro_linux_linker_files",
srcs = [
"//tools/arm_compiler/linaro_linux_gcc:ar",
"//tools/arm_compiler/linaro_linux_gcc:gcc",
"//tools/arm_compiler/linaro_linux_gcc:ld",
"@gcc_linaro_7_3_1_arm_linux_gnueabihf//:compiler_pieces",
],
)
filegroup(
name = "linaro_linux_compiler_files",
srcs = [
"//tools/arm_compiler/linaro_linux_gcc:as",
"//tools/arm_compiler/linaro_linux_gcc:gcc",
"//tools/arm_compiler/linaro_linux_gcc:ld",
],
)
filegroup(
name = "empty",
srcs = [],
)
cc_toolchain(
name = "cc-compiler-armeabi-v7a",
all_files = ":linaro_linux_all_files",
compiler_files = ":linaro_linux_compiler_files",
cpu = "armeabi-v7a",
dwp_files = ":empty",
dynamic_runtime_libs = [":empty"],
linker_files = ":linaro_linux_linker_files",
objcopy_files = "//tools/arm_compiler/linaro_linux_gcc:objcopy",
static_runtime_libs = [":empty"],
strip_files = "//tools/arm_compiler/linaro_linux_gcc:strip",
supports_param_files = 1,
visibility = ["//visibility:public"],
)
major_version: "local"
minor_version: ""
default_target_cpu: "armeabi-v7a"
default_toolchain {
cpu: "armeabi-v7a"
toolchain_identifier: "arm-linux-gnueabihf"
}
toolchain {
abi_version: "gcc"
abi_libc_version: ""
builtin_sysroot: ""
compiler: "gcc"
host_system_name: "armeabi-v7a"
needsPic: true
supports_gold_linker: false
supports_incremental_linker: false
supports_fission: false
supports_interface_shared_objects: false
supports_normalizing_ar: true
supports_start_end_lib: false
supports_thin_archives: true
target_libc: ""
target_cpu: "armeabi-v7a"
target_system_name: ""
toolchain_identifier: "arm-linux-gnueabihf"
tool_path { name: "ar" path: "linaro_linux_gcc/arm-linux-gnueabihf-ar" }
tool_path { name: "compat-ld" path: "linaro_linux_gcc/arm-linux-gnueabihf-ld" }
tool_path { name: "cpp" path: "linaro_linux_gcc/arm-linux-gnueabihf-gcc" }
tool_path { name: "dwp" path: "linaro_linux_gcc/arm-linux-gnueabihf-dwp" }
tool_path { name: "gcc" path: "linaro_linux_gcc/arm-linux-gnueabihf-gcc" }
tool_path { name: "gcov" path: "linaro_linux_gcc/arm-linux-gnueabihf-gcov" }
# C(++) compiles invoke the compiler (as that is the one knowing where
# to find libraries), but we provide LD so other rules can invoke the linker.
tool_path { name: "ld" path: "linaro_linux_gcc/arm-linux-gnueabihf-ld" }
tool_path { name: "nm" path: "linaro_linux_gcc/arm-linux-gnueabihf-nm" }
tool_path { name: "objcopy" path: "linaro_linux_gcc/arm-linux-gnueabihf-objcopy" }
objcopy_embed_flag: "-I"
objcopy_embed_flag: "binary"
tool_path { name: "objdump" path: "linaro_linux_gcc/arm-linux-gnueabihf-objdump" }
tool_path { name: "strip" path: "linaro_linux_gcc/arm-linux-gnueabihf-strip" }
compiler_flag: "--sysroot=external/gcc_linaro_7_3_1_arm_linux_gnueabihf/arm-linux-gnueabihf/libc"
cxx_flag: "-isystem"
cxx_flag: "external/gcc_linaro_7_3_1_arm_linux_gnueabihf/arm-linux-gnueabihf/include/c++/7.3.1/arm-linux-gnueabihf"
cxx_flag: "-isystem"
cxx_flag: "external/gcc_linaro_7_3_1_arm_linux_gnueabihf/arm-linux-gnueabihf/include/c++/7.3.1"
cxx_flag: "-isystem"
cxx_flag: "external/gcc_linaro_7_3_1_arm_linux_gnueabihf/include/c++/7.3.1/arm-linux-gnueabihf"
cxx_flag: "-isystem"
cxx_flag: "external/gcc_linaro_7_3_1_arm_linux_gnueabihf/include/c++/7.3.1"
cxx_builtin_include_directory: "%package(@gcc_linaro_7_3_1_arm_linux_gnueabihf//include)%"
cxx_builtin_include_directory: "%package(@gcc_linaro_7_3_1_arm_linux_gnueabihf//arm-linux-gnueabihf/libc/usr/include)%"
cxx_builtin_include_directory: "%package(@gcc_linaro_7_3_1_arm_linux_gnueabihf//arm-linux-gnueabihf/libc/usr/lib/include)%"
cxx_builtin_include_directory: "%package(@gcc_linaro_7_3_1_arm_linux_gnueabihf//arm-linux-gnueabihf/libc/lib/gcc/arm-linux-gnueabihf/7.3.1/include-fixed)%"
cxx_builtin_include_directory: "%package(@gcc_linaro_7_3_1_arm_linux_gnueabihf//include)%/c++/7.3.1"
cxx_builtin_include_directory: "%package(@gcc_linaro_7_3_1_arm_linux_gnueabihf//arm-linux-gnueabihf/libc/lib/gcc/arm-linux-gnueabihf/7.3.1/include)%"
cxx_builtin_include_directory: "%package(@gcc_linaro_7_3_1_arm_linux_gnueabihf//arm-linux-gnueabihf/libc/lib/gcc/arm-linux-gnueabihf/7.3.1/include-fixed)%"
cxx_builtin_include_directory: "%package(@gcc_linaro_7_3_1_arm_linux_gnueabihf//lib/gcc/arm-linux-gnueabihf/7.3.1/include)%"
cxx_builtin_include_directory: "%package(@gcc_linaro_7_3_1_arm_linux_gnueabihf//lib/gcc/arm-linux-gnueabihf/7.3.1/include-fixed)%"
cxx_builtin_include_directory: "%package(@gcc_linaro_7_3_1_arm_linux_gnueabihf//arm-linux-gnueabihf/include)%/c++/7.3.1"
linker_flag: "--sysroot=external/gcc_linaro_7_3_1_arm_linux_gnueabihf/arm-linux-gnueabihf/libc"
linker_flag: "-fuse-ld=gold"
linker_flag: "-Wl,-no-as-needed"
linker_flag: "-lstdc++"
linker_flag: "-latomic"
linker_flag: "-lm"
linker_flag: "-lpthread"
# Anticipated future default.
# This makes GCC and Clang do what we want when called through symlinks.
unfiltered_cxx_flag: "-no-canonical-prefixes"
linker_flag: "-no-canonical-prefixes"
# Make C++ compilation deterministic. Use linkstamping instead of these
# compiler symbols.
unfiltered_cxx_flag: "-Wno-builtin-macro-redefined"
unfiltered_cxx_flag: "-D__DATE__=\"redacted\""
unfiltered_cxx_flag: "-D__TIMESTAMP__=\"redacted\""
unfiltered_cxx_flag: "-D__TIME__=\"redacted\""
# Security hardening on by default.
# Conservative choice; -D_FORTIFY_SOURCE=2 may be unsafe in some cases.
# We need to undef it before redefining it as some distributions now have
# it enabled by default.
compiler_flag: "-U_FORTIFY_SOURCE"
compiler_flag: "-fstack-protector"
compiler_flag: "-fPIE"
linker_flag: "-v"
linker_flag: "-pie"
linker_flag: "-Wl,-z,relro,-z,now"
# Enable coloring even if there's no attached terminal. Bazel removes the
# escape sequences if --nocolor is specified.
compiler_flag: "-fdiagnostics-color=always"
# All warnings are enabled. Maybe enable -Werror as well?
compiler_flag: "-Wall"
# Enable a few more warnings that aren't part of -Wall.
compiler_flag: "-Wunused-but-set-parameter"
# But disable some that are problematic.
compiler_flag: "-Wno-free-nonheap-object" # has false positives
# Keep stack frames for debugging, even in opt mode.
compiler_flag: "-fno-omit-frame-pointer"
# Stamp the binary with a unique identifier.
linker_flag: "-Wl,--build-id=md5"
linker_flag: "-Wl,--hash-style=gnu"
compilation_mode_flags {
mode: DBG
# Enable debug symbols.
compiler_flag: "-g"
}
compilation_mode_flags {
mode: OPT
# No debug symbols.
# Maybe we should enable https://gcc.gnu.org/wiki/DebugFission for opt or
# even generally? However, that can't happen here, as it requires special
# handling in Bazel.
compiler_flag: "-g0"
# Conservative choice for -O
# -O3 can increase binary size and even slow down the resulting binaries.
# Profile first and / or use FDO if you need better performance than this.
compiler_flag: "-O2"
# Disable assertions
compiler_flag: "-DNDEBUG"
# Removal of unused code and data at link time (can this increase binary size in some cases?).
compiler_flag: "-ffunction-sections"
compiler_flag: "-fdata-sections"
linker_flag: "-Wl,--gc-sections"
}
}
package(default_visibility = ["//tools/arm_compiler:__pkg__"])
filegroup(
name = "srcs",
srcs = glob(["**"]),
visibility = ["//visibility:public"],
)
filegroup(
name = "gcc",
srcs = [
"arm-linux-gnueabihf-gcc",
"@gcc_linaro_7_3_1_arm_linux_gnueabihf//:gcc",
],
)
filegroup(
name = "ar",
srcs = [
"arm-linux-gnueabihf-ar",
"@gcc_linaro_7_3_1_arm_linux_gnueabihf//:ar",
],
)
filegroup(
name = "ld",
srcs = [
"arm-linux-gnueabihf-ld",
"@gcc_linaro_7_3_1_arm_linux_gnueabihf//:ld",
],
)
filegroup(
name = "nm",
srcs = [
"arm-linux-gnueabihf-nm",
"@gcc_linaro_7_3_1_arm_linux_gnueabihf//:nm",
],
)
filegroup(
name = "objcopy",
srcs = [
"arm-linux-gnueabihf-objcopy",
"@gcc_linaro_7_3_1_arm_linux_gnueabihf//:objcopy",
],
)
filegroup(
name = "objdump",
srcs = [
"arm-linux-gnueabihf-objdump",
"@gcc_linaro_7_3_1_arm_linux_gnueabihf//:objdump",
],
)
filegroup(
name = "strip",
srcs = [
"arm-linux-gnueabihf-strip",
"@gcc_linaro_7_3_1_arm_linux_gnueabihf//:strip",
],
)
filegroup(
name = "as",
srcs = [
"arm-linux-gnueabihf-as",
"@gcc_linaro_7_3_1_arm_linux_gnueabihf//:as",
],
)
filegroup(
name = "tool-wrappers",
srcs = [
":ar",
":as",
":gcc",
":ld",
":nm",
":objcopy",
":objdump",
":strip",
],
)
#!/bin/bash --norc
exec -a arm-linux-gnueabihf-ar \
external/gcc_linaro_7_3_1_arm_linux_gnueabihf/bin/arm-linux-gnueabihf-ar \
"$@"
#!/bin/bash --norc
exec -a arm-linux-gnueabihf-as \
external/gcc_linaro_7_3_1_arm_linux_gnueabihf/bin/arm-linux-gnueabihf-as \
"$@"
#!/bin/bash --norc
PATH="external/gcc_linaro_7_3_1_arm_linux_gnueabihf/libexec/gcc/arm-linux-gnueabihf/7.3.1:$PATH" \
exec \
external/gcc_linaro_7_3_1_arm_linux_gnueabihf/bin/arm-linux-gnueabihf-gcc \
"$@"
#!/bin/bash --norc
exec -a arm-linux-gnueabihf-gcov \
external/gcc_linaro_7_3_1_arm_linux_gnueabihf/bin/arm-linux-gnueabihf-gcov \
"$@"
#!/bin/bash --norc
exec -a arm-linux-gnueabihf-ld \
external/gcc_linaro_7_3_1_arm_linux_gnueabihf/bin/arm-linux-gnueabihf-ld \
"$@"
#!/bin/bash --norc
exec -a arm-linux-gnueabihf-nm \
external/gcc_linaro_7_3_1_arm_linux_gnueabihf/bin/arm-linux-gnueabihf-nm \
"$@"
#!/bin/bash --norc
exec -a arm-linux-gnueabihf-objcopy \
external/gcc_linaro_7_3_1_arm_linux_gnueabihf/bin/arm-linux-gnueabihf-objcopy \
"$@"
#!/bin/bash --norc
exec -a arm-linux-gnueabihf-objdump \
external/gcc_linaro_7_3_1_arm_linux_gnueabihf/bin/arm-linux-gnueabihf-objdump \
"$@"
#!/bin/bash --norc
exec -a arm-linux-gnueabihf-strip \
external/gcc_linaro_7_3_1_arm_linux_gnueabihf/bin/arm-linux-gnueabihf-strip \
"$@"
......@@ -17,9 +17,31 @@ build --copt=-DMACE_USE_NNLIB_CAF
build:symbol_hidden --copt=-fvisibility=hidden
# Usage example: bazel build --config android
build:android --config=cross_compile
build:android --crosstool_top=//external:android/crosstool
build:android --host_crosstool_top=@bazel_tools//tools/cpp:toolchain
build:android --config=cross_compile
# Usage example: bazel build --config arm_linux
build:arm_linux --config=cross_compile
build:arm_linux --crosstool_top=//tools/arm_compiler:toolchain
build:arm_linux --host_crosstool_top=@bazel_tools//tools/cpp:toolchain
build:arm_linux --cpu=armeabi-v7a
build:arm_linux --copt -mfloat-abi=hard
build:arm_linux --copt -mfpu=neon
build:arm_linux --copt -Wno-ignored-attributes
build:arm_linux --copt -Wno-unused-function
build:arm_linux --copt -Wno-sequence-point
build:arm_linux --copt -Wno-implicit-fallthrough
# Usage example: bazel build --config aarch64_linux
build:aarch64_linux --config=cross_compile
build:aarch64_linux --crosstool_top=//tools/aarch64_compiler:toolchain
build:aarch64_linux --host_crosstool_top=@bazel_tools//tools/cpp:toolchain
build:aarch64_linux --cpu=aarch64
build:aarch64_linux --copt -Wno-ignored-attributes
build:aarch64_linux --copt -Wno-unused-function
build:aarch64_linux --copt -Wno-sequence-point
build:aarch64_linux --copt -Wno-implicit-fallthrough
# Usage example: bazel build --config optimization
build:optimization -c opt
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册