我使用自定义工具链编译tensorflow作为网站https://github.com/bazelbuild/bazel/wiki/Building-with-a-custom-toolchain。 但它无法正常工作,请帮我解决。
壳:
bazel build --crosstool_top = // tools / arm_compiler:toolchain --cpu = armeabi-v7a tensorflow / examples / speech_commands:test_streaming_accuracy
错误日志如下:
错误: /home/billy/.cache/bazel/_bazel_billy/b6316091758c6a5954b4681b7e92ef65/external/bazel_tools/tools/cpp/BUILD:12:1: 目标'// tools / arm_compiler:cc-compiler-local'从中看不到 target'@ bazel_tools // tools / cpp:stl'。检查可见性声明 如果你认为依赖是合法的,那么前一个目标是错误的: 目标分析 '// tensorflow /示例/ speech_commands:test_streaming_accuracy' 失败;建立中止:目标分析 '@ bazel_tools // tools / cpp:stl'失败;建立中止信息:经过 时间:0.325秒失败:构建未成功完成(1个包 加载) 目前正在加载:@protobuf_archive //
WORKSPACE:
workspace(name = "org_tensorflow")
http_archive(
name = "io_bazel_rules_closure",
sha256 = "6691c58a2cd30a86776dd9bb34898b041e37136f2dc7e24cadaeaf599c95c657",
strip_prefix = "rules_closure-08039ba8ca59f64248bb3b6ae016460fe9c9914f",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_closure/archive/08039ba8ca59f64248bb3b6ae016460fe9c9914f.tar.gz",
"https://github.com/bazelbuild/rules_closure/archive/08039ba8ca59f64248bb3b6ae016460fe9c9914f.tar.gz", # 2018-01-16
],
)
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_repositories")
closure_repositories()
load("//tensorflow:workspace.bzl", "tf_workspace")
# Uncomment and update the paths in these entries to build the Android demo.
android_sdk_repository(
name = "androidsdk",
api_level = 23,
# Ensure that you have the build_tools_version below installed in the
# SDK manager as it updates periodically.
build_tools_version = "26.0.2",
# Replace with path to Android SDK on your system
path = "/usr/local/android_sdk",
)
android_ndk_repository(
name="androidndk",
path="/usr/local/android-ndk-r12b",
# This needs to be 14 or higher to compile TensorFlow.
# Please specify API level to >= 21 to build for 64-bit
# archtectures or the Android NDK will automatically select biggest
# API level that it supports without notice.
# Note that the NDK version is not the API level.
api_level=14)
# Please add all new TensorFlow dependencies in workspace.bzl.
tf_workspace()
new_http_archive(
name = "inception_v1",
build_file = "models.BUILD",
sha256 = "7efe12a8363f09bc24d7b7a450304a15655a57a7751929b2c1593a71183bb105",
urls = [
"http://storage.googleapis.com/download.tensorflow.org/models/inception_v1.zip",
"http://download.tensorflow.org/models/inception_v1.zip",
],
)
new_http_archive(
name = "mobile_ssd",
build_file = "models.BUILD",
sha256 = "bddd81ea5c80a97adfac1c9f770e6f55cbafd7cce4d3bbe15fbeb041e6b8f3e8",
urls = [
"http://storage.googleapis.com/download.tensorflow.org/models/object_detection/ssd_mobilenet_v1_android_export.zip",
"http://download.tensorflow.org/models/object_detection/ssd_mobilenet_v1_android_export.zip",
],
)
new_http_archive(
name = "mobile_multibox",
build_file = "models.BUILD",
sha256 = "859edcddf84dddb974c36c36cfc1f74555148e9c9213dedacf1d6b613ad52b96",
urls = [
"http://storage.googleapis.com/download.tensorflow.org/models/mobile_multibox_v1a.zip",
"http://download.tensorflow.org/models/mobile_multibox_v1a.zip",
],
)
new_http_archive(
name = "stylize",
build_file = "models.BUILD",
sha256 = "3d374a730aef330424a356a8d4f04d8a54277c425e274ecb7d9c83aa912c6bfa",
urls = [
"http://storage.googleapis.com/download.tensorflow.org/models/stylize_v1.zip",
"http://download.tensorflow.org/models/stylize_v1.zip",
],
)
new_http_archive(
name = "speech_commands",
build_file = "models.BUILD",
sha256 = "c3ec4fea3158eb111f1d932336351edfe8bd515bb6e87aad4f25dbad0a600d0c",
urls = [
"http://storage.googleapis.com/download.tensorflow.org/models/speech_commands_v0.01.zip",
"http://download.tensorflow.org/models/speech_commands_v0.01.zip",
],
)
new_http_archive(
name = 'linaroLinuxGcc49Repo',
build_file = 'compilers/linaro_linux_gcc_5.5.BUILD',
url = 'http://releases.linaro.org/components/toolchain/binaries/latest-5/arm-linux-gnueabihf/gcc-linaro-5.5.0-2017.10-x86_64_arm-linux-gnueabihf.tar.xz',
strip_prefix = 'gcc-linaro-5.5.0-2017.10-x86_64_arm-linux-gnueabihf',
)
arm_compiler / BUILD:
# This is the entry point for --crosstool_top.
#
# The cc_toolchain rule used is found by:
#
# 1. Finding the appropriate toolchain in the CROSSTOOL file based on the --cpu
# and --compiler command line flags (if they exist, otherwise using the
# "default_target_cpu" / "default_toolchain" fields in the CROSSTOOL file)
# 2. Concatenating the "target_cpu" and "compiler" fields of the toolchain in
# use and using that as a key in the map in the "toolchains" attribute
cc_toolchain_suite(
name = 'toolchain',
toolchains = {
'armeabi-v7a|clang': ':cc-compiler-armeabi-v7a',
"k8|compiler": ":cc-compiler-local",
},
)
filegroup(
name = 'linaro_linux_all_files',
srcs = [
'//tools/arm_compiler/linaro_linux_gcc:clang-symlinks',
'//tools/arm_compiler/linaro_linux_gcc:tool-wrappers',
'@linaroLinuxGcc49Repo//:compiler_pieces',
],
)
filegroup(
name = 'linaro_linux_linker_files',
srcs = [
'//tools/arm_compiler/linaro_linux_gcc:gcc',
'//tools/arm_compiler/linaro_linux_gcc:ld',
'//tools/arm_compiler/linaro_linux_gcc:ar',
'//tools/arm_compiler/linaro_linux_gcc:clang-ld',
'//tools/arm_compiler/linaro_linux_gcc:clang',
'@linaroLinuxGcc49Repo//:compiler_pieces',
],
)
filegroup(
name = 'linaro_linux_compiler_files',
srcs = [
'//tools/arm_compiler/linaro_linux_gcc:gcc',
'//tools/arm_compiler/linaro_linux_gcc:ld',
'//tools/arm_compiler/linaro_linux_gcc:clang',
'//tools/arm_compiler/linaro_linux_gcc:as',
],
)
cc_toolchain(
name = 'cc-compiler-armeabi-v7a',
all_files = '//tools/arm_compiler:linaro_linux_all_files',
compiler_files = '//tools/arm_compiler:linaro_linux_compiler_files',
cpu = 'armeabi-v7a',
dwp_files = ':empty',
dynamic_runtime_libs = [':empty'],
linker_files = '//tools/arm_compiler: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,
)
cc_toolchain(
name = "cc-compiler-local",
all_files = ":empty",
compiler_files = ":empty",
cpu = "local",
dwp_files = ":empty",
dynamic_runtime_libs = [":empty"],
linker_files = ":empty",
objcopy_files = ":empty",
static_runtime_libs = [":empty"],
strip_files = ":empty",
supports_param_files = 1,
)
arm_compiler / crosstool的:
major_version: "5"
minor_version: "5"
default_target_cpu: "armeabi-v7a"
default_toolchain {
cpu: "armeabi-v7a"
toolchain_identifier: "clang_linux_armhf"
}
default_toolchain {
cpu: "k8"
toolchain_identifier: "local"
}
toolchain {
abi_version: "clang_3.6"
abi_libc_version: "glibc_2.19"
builtin_sysroot: ""
compiler: "clang"
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: "glibc_2.19"
target_cpu: "armeabi-v7a"
target_system_name: "arm_a15"
toolchain_identifier: "clang_linux_armhf"
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/clang_bin/clang" }
tool_path { name: "dwp" path: "linaro_linux_gcc/arm-linux-gnueabihf-dwp" }
tool_path { name: "gcc" path: "linaro_linux_gcc/clang_bin/clang" }
tool_path { name: "gcov" path: "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-gcov-5.5" }
# 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: "-target"
compiler_flag: "armv7a-arm-linux-gnueabif"
compiler_flag: "--sysroot=external/linaroLinuxGcc49Repo/arm-linux-gnueabihf/libc"
compiler_flag: "-mfloat-abi=hard"
compiler_flag: "-nostdinc"
compiler_flag: "-isystem"
compiler_flag: "/usr/lib/clang/3.6/include"
compiler_flag: "-isystem"
compiler_flag: "external/linaroLinuxGcc49Repo/lib/gcc/arm-linux-gnueabihf/5.5.0/include"
compiler_flag: "-isystem"
compiler_flag: "external/linaroLinuxGcc49Repo/arm-linux-gnueabihf/libc/usr/include"
compiler_flag: "-isystem"
compiler_flag: "external/linaroLinuxGcc49Repo/lib/gcc/arm-linux-gnueabihf/5.5.0/include-fixed"
compiler_flag: "-isystem"
compiler_flag: "external/linaroLinuxGcc49Repo/arm-linux-gnueabihf/libc/usr/include"
cxx_flag: "-isystem"
cxx_flag: "external/linaroLinuxGcc49Repo/arm-linux-gnueabihf/include/c++/5.5.0/arm-linux-gnueabihf"
cxx_flag: "-isystem"
cxx_flag: "external/linaroLinuxGcc49Repo/arm-linux-gnueabihf/include/c++/5.5.0"
cxx_flag: "-isystem"
cxx_flag: "external/linaroLinuxGcc49Repo/include/c++/5.5.0/arm-linux-gnueabihf"
cxx_flag: "-isystem"
cxx_flag: "external/linaroLinuxGcc49Repo/include/c++/5.5.0"
cxx_builtin_include_directory: "%package(@linaroLinuxGcc49Repo)%//include"
cxx_builtin_include_directory: "%package(@linaroLinuxGcc49Repo)%//arm-linux-gnueabihf/libc/usr/include"
cxx_builtin_include_directory: "%package(@linaroLinuxGcc49Repo)%//arm-linux-gnueabihf/libc/usr/lib/include"
cxx_builtin_include_directory: "%package(@linaroLinuxGcc49Repo)%//arm-linux-gnueabihf/libc/lib/gcc/arm-linux-gnueabihf/5.5.0/include-fixed"
cxx_builtin_include_directory: "%package(@linaroLinuxGcc49Repo)%//include/c++/5.5.0"
cxx_builtin_include_directory: "%package(@linaroLinuxGcc49Repo)%//arm-linux-gnueabihf/libc/lib/gcc/arm-linux-gnueabihf/5.5.0/include"
cxx_builtin_include_directory: "%package(@linaroLinuxGcc49Repo)%//arm-linux-gnueabihf/libc/lib/gcc/arm-linux-gnueabihf/5.5.0/include-fixed"
cxx_builtin_include_directory: "%package(@linaroLinuxGcc49Repo)%//lib/gcc/arm-linux-gnueabihf/5.5.0/include"
cxx_builtin_include_directory: "%package(@linaroLinuxGcc49Repo)%//lib/gcc/arm-linux-gnueabihf/5.5.0/include-fixed"
cxx_builtin_include_directory: "%package(@linaroLinuxGcc49Repo)%//arm-linux-gnueabihf/include)%/c++/5.5.0"
cxx_builtin_include_directory: '/usr/lib/clang/3.6/include'
linker_flag: "-target"
linker_flag: "armv7a-arm-linux-gnueabif"
linker_flag: "--sysroot=external/linaroLinuxGcc49Repo/arm-linux-gnueabihf/libc"
linker_flag: "-lstdc++"
linker_flag: "-Ltools/arm_compiler/linaro_linux_gcc/clang_more_libs"
linker_flag: "-Lexternal/linaroLinuxGcc49Repo/arm-linux-gnueabihf/lib"
linker_flag: "-Lexternal/linaroLinuxGcc49Repo/arm-linux-gnueabihf/libc/lib"
linker_flag: "-Lexternal/linaroLinuxGcc49Repo/arm-linux-gnueabihf/libc/usr/lib"
linker_flag: "-Lexternal/linaroLinuxGcc49Repo/arm-linux-gnueabihf/bin"
linker_flag: "-Wl,--dynamic-linker=/lib/ld-linux-armhf.so.3"
# 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: "-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"