bazel构建aot工具在平台上失败。未找到致命错误“互斥体”文件

时间:2021-08-21 14:33:06

I am trying aot cross compiling with bazel.But failed in platform.h fatal error 'mutex' file not found.I can build with bazel without cross compile setting, and I can exec the binary in host.

我正在尝试用bazel编译aot交叉编译。但没有在平台。未找到致命错误“互斥体”文件。我可以使用bazel构建而无需交叉编译设置,并且我可以在主机中执行二进制。

My environment is below

我的环境下面

  • x86-64 ubuntu14.04
  • x86 - 64 ubuntu14.04
  • target:arm-linux-gnueabihf
  • 目标:arm-linux-gnueabihf
  • tensorflow:Head of maste cd5f3b67fca88217776522182481b0c128db5af9
  • tensorflow:主管maste cd5f3b67fca88217776522182481b0c128db5af9
  • bazel:0.5.4 installed by apt-get install
  • bazel:由apt-get安装安装的0.5.4

My test code is below.

我的测试代码在下面。

#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;
}

I modified the some files to compile.

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

  1. add cross compile setting to WORKSPACE file

    向工作区文件添加交叉编译设置

    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", )

    new_local_repository(名称=“linaroLinuxGcc49Repo”,build_file =“编译器/linaro_linux_gcc_4.9”)。构建",path = "编译器/gcc-linaro-4.9-2016.02-x86 _64_ arm-linux-gnueabihf"

  2. add build setting in /tensorflow/compiler/aot/tests/BUILD

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

    cc_binary( name = "my_binary", srcs = [ "my_code.cc", # include test_graph_tfmatmul.h to access the generated header ], deps = [ ":test_graph_tfmatmul", # link in the generated object file "//third_party/eigen3", ], linkopts = [ "-lpthread", ] )

    cc_binary(name = "my_binary", srcs = "my_code "。cc”,# include test_graph_tfmatmul。h访问生成的报头],deps = [":test_graph_tfmatmul",在生成的对象文件"//third_party/特征3"中的#链接,],linkopts = ["-lpthread",]

Below is the build command I did.

下面是我所做的构建命令。

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

bazel构建—copt=-Wno-c+ 11-narrow -cxxopt='-std=c+ 11' //tensorflow/编译器/aot/tests:my_binary—host_crosstool_top=@bazel_tools// failure /cpp:toolchain—crosstool_top=/ tools/ tools/ tools/ tools/ tools/ tools/ tools// server / arab_varabi -

Finally I get the error below.

最后我得到了下面的错误。

(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 WARNING: /home/user-name/tensorflow/repo/tensorflow/core/BUILD:1772:1: in includes attribute of cc_library rule //tensorflow/core:framework_headers_lib: '../../external/nsync/public' resolves to 'external/nsync/public' not below the relative path of its package 'tensorflow/core'. This will be an error in the future. Since this rule was created by the macro 'cc_header_only_library', the error might have been caused by the macro implementation in /home/user-name/tensorflow/repo/tensorflow/tensorflow.bzl:1029:30 WARNING: /home/user-name/tensorflow/repo/tensorflow/contrib/learn/BUILD:15:1: in py_library rule //tensorflow/contrib/learn:learn: target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:exporter': No longer supported. Switch to SavedModel immediately. WARNING: /home/user-name/tensorflow/repo/tensorflow/contrib/learn/BUILD:15:1: in py_library rule //tensorflow/contrib/learn:learn: target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:gc': No longer supported. Switch to SavedModel immediately. INFO: Analysed target //tensorflow/compiler/aot/tests:my_binary (0 packages loaded). INFO: Found 1 target... ERROR: /home/user-name/.cache/bazel/_bazel_user-name/6d2eb697f6f4dfadad89ea8a861fded5/external/nsync/BUILD:397:1: C++ compilation of rule '@nsync//:nsync_cpp' failed (Exit 1): clang failed: error executing command (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/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 '-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 -iquote 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 -x c++ '-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) warning: unknown warning option '-Wunused-but-set-parameter'; did you mean '-Wunused-parameter'? [-Wunknown-warning-option] warning: unknown warning option '-Wno-free-nonheap-object'; did you mean '-Wno-sequence-point'? [-Wunknown-warning-option] In file included from external/nsync/internal/sem_wait.c:16: ./external/nsync//platform/c++11/platform.h:29:10: fatal error: 'mutex' file not found #include ^ 2 warnings and 1 error generated. Target //tensorflow/compiler/aot/tests:my_binary failed to build INFO: Elapsed time: 0.917s, Critical Path: 0.15s FAILED: Build did NOT complete successfully

(root) user-name@machine-name:repo [master]$ bazel build——copt=-Wno-c+ 11-narrow -cxxopt='-std=c+ 11' // /tensorflow/compiler/aot/tests:/external/nsync/public将解析为“external/nsync/public”,而非其包“tensorflow/core”的相对路径。这将是未来的一个错误。由于这条规则是由宏“cc_header_only_library”创建的,所以错误可能是由/home/user-name/tensorflow/repo/tensorflow中的宏实现引起的。警告:/home/user-name/tensorflow/repo/ tensorflow/learb/learn/build:15:1:在py_library规则//tensorflow/后悔/学习:目标/后悔/后悔/后悔/学习:学习“取决于不赞成的目标”立即切换到SavedModel。警告:/home/user- name/tensorflow/tensorflow /悔过/ learn/build:15:1:在py_library规则/tensorflow/懊悔/悔过/学习:learn: target '//tensorflow/悔过/learn:learn'取决于弃用的目标'/ tensorflow/悔过流/session_bundle:没有。立即切换到SavedModel。分析目标// /tensorflow/编译器/aot/测试:my_binary (0 package loaded)。信息:发现1目标…错误:/home/user-name/.缓存/bazel/_bazel_user-name/ 6d2eb697f6f6f4dfadad89ea8a861fded5 /external/nsync/BUILD:397:1: c++编译规则‘@nsync// //:nsync_cpp’失败(退出1):clang失败:执行命令错误(home/ home/user- namecd)。缓存/ bazinel_bazel_user -name/ 6d697f6f4dfadad89ea8a861fabided5 /execroot/org_tensorflow & \ exec env - \ pv =/proc/self/ \ PYTHON_BIN_PATH=包括-isystem / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /-fdiagnostics-color=always -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit- omit- omit-指针-g0 -g0 -O2 -DNDEBUG - ffunc- sections -fno- c+ 11- -MD -MF bazel-out/clang_linux_armhf- framhf_py3 - nopt-iquote external/nsync -iquote bazel-out/ clang_linux_py3 -opt/genfiles/external/nsync -iquote external/bazel_tools -iquote bazel- bazel- bazel- bazel-out/ clang_linux_py3 - pyh3 -opt/ arm3 -opt/ bazel_外部性/ bazel_sync /bazel_tools/外部/ nsync / /平台/ c++ 11 - i。/外部/ nsync / /平台/ gcc -我。/外部/ nsync / /平台/手臂- i。外部/ nsync / /公共- i。/外部/ nsync / /内部-我。/external/nsync/ platform/posix '-D_POSIX_C_SOURCE=200809L' -pthread -no-canonical- wno -builtin-macro redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' - d___time__ ="redacted" / _sync " internal -c external/nsync "c -o bazel-out/clang_linux_armhf-py3-opt/bin/external/nsync/_objs/nsync_cpp/external/nsync/ nsync/internal/sem_wait.o)警告:未知警告选项'- wunuse -but-set-parameter';你的意思是“-Wunused-parameter”?警告:未知的警告选项'- wno -free-nonheap对象';你的意思是“-Wno-sequence-point”?从外部/nsync/内部/sem_wait中包含的文件。c:16:。/外部/ nsync / /平台/ c++ 11 /平台。h:29:10:致命错误:“互斥”文件未找到# include ^ 2警告和1产生的误差。目标//tensorflow/编译器/aot/测试:my_binary未能生成信息:运行时间:0.917s,关键路径:0.15s失败:构建没有成功完成。

Error occures in "C++ compilation of rule '@nsync//:nsync_cpp' failed (Exit 1):" .

“c++编译规则‘@nsync//:nsync_cpp’失败(退出1):”时发生错误。

Befause of "./external/nsync//platform/c++11/platform.h:29:10: fatal error: 'mutex' file not found #include "

Befause”。/外部/ nsync / /平台/ c++ 11 /平台。h:29:10:致命错误:'mutex'文件未找到#include '

The file mutex is exist in ./compilers/gcc-linaro-4.9-2016.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/4.9.4/mutex.

互斥文件存在于./编译器/gcc-linaro-4.9-2016.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/4.9.4/互斥文件中。

I think path above is setted in the build output line "-isystem external/linaroLinuxGcc49Repo/include/c++/4.9.4"

我认为上面的路径设置在构建输出线中“-isystem外部/linaroLinuxGcc49Repo/include/c++/4.9.4”

How could I set the path to mutex? for cross compiling nsync?

如何设置到互斥对象的路径?交叉编译nsync吗?

1 个解决方案

#1


0  

I made a mistake when I edit CROSSTOOL file. If you know detail, please refer below.

我在编辑横排文件时犯了一个错误。如果你知道详情,请参考下面。

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

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

thanks!

谢谢!

#1


0  

I made a mistake when I edit CROSSTOOL file. If you know detail, please refer below.

我在编辑横排文件时犯了一个错误。如果你知道详情,请参考下面。

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

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

thanks!

谢谢!