首页 文章

bazel使用cross tool构建aot在platform.h中失败致命错误'mutex'找不到文件

提问于
浏览
1

我正在尝试使用bazel进行交叉编译 . 但是在platform.h中失败了致命错误'mutex'文件未找到 . 我可以使用bazel构建而无需交叉编译设置,我可以在主机中执行二进制文件 .

我的环境如下

  • x86-64 ubuntu14.04

  • target:arm-linux-gnueabihf

  • tensorflow:掌握cd5f3b67fca88217776522182481b0c128db5af9

  • bazel:由apt-get install安装的0.5.4

我的测试代码如下 .

#define EIGEN_USE_THREADS
#define EIGEN_USE_CUSTOM_THREAD_POOL

#include <iostream>
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
#include "tensorflow/compiler/aot/tests/test_graph_tfmatmul.h" // generated

int main(int argc, char** argv) {
  Eigen::ThreadPool tp(2);  // Size the thread pool as appropriate.
  Eigen::ThreadPoolDevice device(&tp, tp.NumThreads());

  foo::bar::MatMulComp matmul;
  matmul.set_thread_pool(&device);

  // Set up args and run the computation.
  const float args[12] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
  std::copy(args + 0, args + 6, matmul.arg0_data());
  std::copy(args + 6, args + 12, matmul.arg1_data());
  matmul.Run();

  // Check result
  if (matmul.result0(0, 0) == 58) {
    std::cout << "Success" << std::endl;
  } else {
    std::cout << "Failed. Expected value 58 at 0,0. Got:"
              << matmul.result0(0, 0) << std::endl;
  }

  return 0;
}

我修改了一些文件进行编译 .

  • 将交叉编译设置添加到WORKSPACE文件

new_local_repository(name =“linaroLinuxGcc49Repo”,build_file =“compilers / linaro_linux_gcc_4.9.BUILD”,path =“compilers / gcc-linaro-4.9-2016.02-x86_64_arm-linux-gnueabihf”,)

  • 在/ tensorflow / compiler / aot / tests / BUILD中添加构建设置

cc_binary(name =“my_binary”,srcs = [“my_code.cc”,#include test_graph_tfmatmul.h访问生成的 Headers ],deps = [“:test_graph_tfmatmul”,生成的目标文件中的#link“// third_party / eigen3“,],linkopts = [” - lpthread“,])

下面是我做的构建命令 .

bazel build --copt = -Wno -c 11-narrowing --cxxopt =' - std = c 11'// tensorflow / compiler / aot / tests:my_binary --host_crosstool_top = @ bazel_tools // tools / cpp:toolchain - -crosstool_top = // tools / arm_compiler:toolchain --cpu = armeabi-v7a --verbose_failures

最后我收到以下错误 .

(root)user-name @ machine-name:repo [master] $ bazel build --copt = -Wno -c 11-narrowing --cxxopt =' - std = c 11'// tensorflow / compiler / aot / tests :my_binary --host_crosstool_top = @ bazel_tools // tools / cpp:toolchain --crosstool_top = // tools / arm_compiler:toolchain --cpu = armeabi-v7a --verbose_failures警告:/ home / user-name / tensorflow / repo / tensorflow / core / BUILD:1772:1:in包含cc_library规则的属性// tensorflow / core:framework_headers_lib:'../../ external / nsync / public'解析为'external / nsync / public'而不是相对路径下面其包装'tensorflow / core' . 这将是一个错误 . 由于此规则是由宏“cc_header_only_library”创建的,因此错误可能是由/home/user-name/tensorflow/repo/tensorflow/tensorflow.bzl:1029:30中的宏实现引起的 . 警告:/ home / user- name / tensorflow / repo / tensorflow / contrib / learn / BUILD:15:1:在py_library规则中// tensorflow / contrib / learn:learn:target'// tensorflow / contrib / learn:learn'取决于弃用的目标'// tensorflow / contrib / session_bundle:exporter':不再支持 . 立即切换到SavedModel . 警告:/ home / user-name / tensorflow / repo / tensorflow / contrib / learn / BUILD:15:1:在py_library规则// tensorflow / contrib / learn:learn:target'// tensorflow / contrib / learn:learn'取决于弃用的目标'// tensorflow / contrib / session_bundle:gc':不再支持 . 立即切换到SavedModel . 信息:分析目标// tensorflow / compiler / aot / tests:my_binary(已加载0个包) . 信息:找到1个目标...错误:/home/user-name/.cache/bazel/_bazel_user-name/6d2eb697f6f4dfadad89ea8a861fded5/external/nsync/BUILD:397:1:C编译规则'@snsync //:nsync_cpp'失败(退出1):clang失败:错误执行命令(cd /home/user-name/.cache/bazel/_bazel_user-name/6d2eb697f6f4dfadad89ea8a861fded5/execroot/org_tensorflow&& \ exec env - \ PWD = / proc / self / cwd \ PYTHON_BIN_PATH = / home / user-name / .pyenv / versions / anaconda3-4.4.0 / bin / python \ PYTHON_LIB_PATH = / home / user-name / .pyenv / versions / anaconda3-4.4.0 / lib / python3.6 / site-packages \ TF_NEED_CUDA = 0 \ TF_NEED_OPENCL = 0 \ tools / arm_compiler / linaro_linux_gcc / clang_bin / clang -target armv7a-arm-linux-gnueabif'-sysroot = external / linaroLinuxGcc49Repo / arm-linux-gnueabihf / libc''-mfloat -abi = hard'-nostdinc -isystem /usr/lib/clang/3.6/include-isystem external / linaroLinuxGcc49Repo / lib / gcc / arm-linux-gnueabihf / 4.9.4 / include -isystem external / linaroLinuxGcc49Repo / arm-linux- gnueabihf / libc / usr / include -isystem external / linaroLinuxGcc49 Repo / lib / gcc / arm-linux-gnueabihf / 4.9.4 / include-fixed -isystem external / linaroLinuxGcc49Repo / arm-linux-gnueabihf / libc / usr / include -isystem external / linaroLinuxGcc49Repo / include / c /4.9.4 - U_FORTIFY_SOURCE -fstack-protector -fPIE'-fdiagnostics-color = always'-Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 -DNDEBUG -ffunction- sections -fdata-sections -Wno -c 11-narrowing -MD -MF bazel-out / clang_linux_armhf-py3-opt / bin / external / nsync / _objs / nsync_cpp / external / nsync / internal / sem_wait.d -iquote external / nsync -我引用bazel-out / clang_linux_armhf-py3-opt / genfiles / external / nsync -iquote external / bazel_tools -iquote bazel-out / clang_linux_armhf-py3-opt / genfiles / external / bazel_tools -isystem external / nsync / public -isystem bazel-out / clang_linux_armhf-py3-opt / genfiles / external / nsync / public -isystem external / bazel_tools / tools / cpp / gcc3 -xc'-std = c 11'-DNSYNC_ATOMIC_CPP11 -DNSYNC_USE_CPP11_TIMEPOINT -I./external/nsync//platform/c 11 -I./external/nsync//platform/gcc -I./external/nsync//platform/arm -I./external/nsync//public -I./external/nsync//internal -I./external/ nsync // platform / posix'-D_POSIX_C_SOURCE = 200809L'-pthread -no-canonical-prefixes -Wno-builtin-macro-redefined'-D__DATE __ =“redacted”''-D__TIMESTAMP __ =“redacted”''-D__TIME __ =“redacted “'-c external / nsync / internal / sem_wait.c -o bazel-out / clang_linux_armhf-py3-opt / bin / external / nsync / _objs / nsync_cpp / external / nsync / internal / sem_wait.o)警告:未知警告选项'-Wunused-但设定参数';你的意思是'-Wunused-parameter'? [-Wunknown-warning-option]警告:未知警告选项'-Wno-free-nonheap-object';你的意思是'-Wno-sequence-point'? [-Wunknown-warning-option]在external / nsync / internal / sem_wait.c中包含的文件中:16:./ external / nsync//platform / c 11 / platform.h:29:10:致命错误:'mutex'找不到文件#include ^ 2警告并生成1个错误 . 目标// tensorflow / compiler / aot / tests:my_binary无法构建INFO:经过时间:0.917s,关键路径:0.15s FAILED:构建未成功完成

“C编译规则'@nsync //:nsync_cpp'失败(退出1)时出现错误:” .

因为“./external/nsync//platform/c 11 / platform.h:29:10:致命错误:找不到'互斥'文件#include”

文件互斥锁存在于./compilers/gcc-linaro-4.9-2016.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/include/c /4.9.4/mutex中 .

我认为上面的路径是在构建输出行“-isystem external / linaroLinuxGcc49Repo / include / c /4.9.4”中设置的

我怎样才能设置互斥锁的路径?用于交叉编译nsync?

1 回答

相关问题