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

时间:2017-09-28 07:05:20

标签: tensorflow cross-compiling aot

我正在尝试与bazel进行交叉编译。但是在platform.h中失败了致命错误' mutex'找不到文件。我可以在没有交叉编译设置的情况下用bazel构建,我可以在主机中执行二进制文件。

我的环境低于

  • x86-64 ubuntu14.04
  • 目标:臂-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;
}

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

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

      

    new_local_repository(name =&#34; linaroLinuxGcc49Repo&#34;,build_file =   &#34;编译器/ linaro_linux_gcc_4.9.BUILD&#34;,path =   &#34;编译器/ gcc-linaro-4.9-2016.02-x86_64_arm-linux-gnueabihf&#34;,)

  2. 在/ tensorflow / compiler / aot / tests / BUILD

    中添加构建设置
      

    cc_binary(       name =&#34; my_binary&#34;,       srcs = [           &#34; my_code.cc&#34;,#include test_graph_tfmatmul.h访问生成的标题       ]       deps = [           &#34;:test_graph_tfmatmul&#34;,#生成的目标文件中的链接           &#34; // THIRD_PARTY / eigen3&#34 ;,       ]       linkopts = [             &#34; -lpthread&#34 ;,       ])

  3. 下面是我做的构建命令。

      

    bazel build --copt = -Wno-c ++ 11-narrowing --cxxopt =&#39; -std = c ++ 11&#39;   // tensorflow /编译器/ AOT /测试: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 =&#39; -std = C ++ 11&#39; // 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:&#39; ../../ external / nsync / public&#39;   解析为&#39; external / nsync / public&#39;不低于它的相对路径   package&#39; tensorflow / core&#39;。这将是一个错误。以来   此规则是由宏&#39; cc_header_only_library&#39;,错误创建的   可能是由宏实现引起的   /home/user-name/tensorflow/repo/tensorflow/tensorflow.bzl:1029:30   警告:   /家庭/用户名/ tensorflow /回购/ tensorflow /的contrib /学习/ BUILD:15:1:   在py_library规则// tensorflow / contrib / learn:learn:target   &#39; // tensorflow /的contrib /学习:学习&#39;取决于弃用的目标   &#39; // tensorflow / contrib / session_bundle:exporter&#39;:不再支持。   立即切换到SavedModel。警告:   /家庭/用户名/ tensorflow /回购/ tensorflow /的contrib /学习/ BUILD:15:1:   在py_library规则// tensorflow / contrib / learn:learn:target   &#39; // tensorflow /的contrib /学习:学习&#39;取决于弃用的目标   &#39; // tensorflow / contrib / session_bundle:gc&#39;:不再支持。开关   立即保存模型。信息:分析目标   // tensorflow / compiler / aot / tests:my_binary(已加载0个包)。信息:   找到1个目标...错误:   /home/user-name/.cache/bazel/_bazel_user-name/6d2eb697f6f4dfadad89ea8a861fded5/external/nsync/BUILD:397:1:   C ++编译规则&#39; @nsync //:nsync_cpp&#39;失败(退出1):铿锵   失败:错误执行命令(cd   /home/user-name/.cache/bazel/_bazel_user-name/6d2eb697f6f4dfadad89ea8a861fded5/execroot/org_tensorflow   &安培;&安培; \ exec env - \       PWD = / proc / self / cwd \       PYTHON_BIN_PATH = /家庭/用户名/ .pyenv /版本/ anaconda3-4.4.0 /斌/蟒蛇   \       PYTHON_LIB_PATH = /家庭/用户名/ .pyenv /版本/ 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臂-Linux的gnueabif   &#39; - SYSROOT =外部/ linaroLinuxGcc49Repo /臂-Linux的gnueabihf / libc的&#39;   &#39; -mfloat-ABI =硬&#39; -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 / linaroLinuxGcc49Repo / 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&#39; -fdiagnostics-color = always&#39; -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 -iquote bazel-out / clang_linux_armhf-py3-opt / genfiles / external / nsync -iquote   external / bazel_tools -iquote   巴泽尔输出/ clang_linux_armhf-PY 3-OPT / genfiles /外部/ 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 -x c ++&#39; -std = c ++ 11&#39; -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&-39--D_POSIX_C_SOURCE = 200809L&#39; -pthread -no-canonical-prefixes   -Wno-builtin-macro-redefined&#39; -D__DATE __ =&#34;编辑&#34;&#39; &#39; -D__TIMESTAMP __ =&#34;删节&#34;&#39; &#39; -D__TIME __ =&#34;删节&#34;&#39; -C   external / nsync / internal / sem_wait.c -o   巴泽勒输出/ clang_linux_armhf-PY3-OPT / bin中/外部/的Nsync / _objs / nsync_cpp /外部/的Nsync /内部/ sem_wait.o)   警告:未知警告选项&#39; -Wunused-but-set-parameter&#39 ;;你是否   意味着&#39; -Wunused-parameter&#39 ;? [-Wunknown-warning-option]警告:未知   警告选项&#39; -Wno-free-nonheap-object&#39 ;;你的意思是   &#39; -Wno序列点&#39 ;? [-Wunknown-warning-option]包含在文件中   来自external / nsync / internal / sem_wait.c:16:   ./external/nsync//platform/c++11/platform.h:29:10:致命错误:   &#39;互斥&#39;文件未找到   #包括            ^ 2警告和1错误生成。目标// tensorflow / compiler / aot / tests:my_binary无法构建INFO:   经过时间:0.917s,关键路径:0.15s失败:构建没有   顺利完成

    &#34; C ++编译规则&#39; @nsync //:nsync_cpp&#39;出现错误失败(退出1):&#34;

    因为&#34; ./ external / nsync // platform / c ++ 11 / platform.h:29:10:致命错误:&#39;互斥&#39;文件未找到 #包括 &#34;

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

    我认为上面的路径是在构建输出行中设置的&#34; -isystem external / linaroLinuxGcc49Repo / include / c ++ / 4.9.4&#34;

    如何设置互斥锁的路径?用于交叉编译nsync?

1 个答案:

答案 0 :(得分:0)

编辑CROSSTOOL文件时出错了。 如果您了解详情,请参阅下文。

https://github.com/bazelbuild/bazel/issues/3836

谢谢!